Advertisement
Avdluna

Untitled

May 10th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.    long long y=0;
  9.    int x[100005],z,n;
  10.  
  11.         scanf("%d",&n);
  12.             for(int i=0;i<n;i++){
  13.                 scanf("%d",&x[i]);
  14.                     y +=x[i];
  15.             }
  16.                 if(y%2==0){
  17.                     printf("%lld\n",y);
  18.                 }
  19.                     else{
  20.                         sort(x,x+n);
  21.                             for(int i=0;i<n;i++){
  22.                               if(x[i]%2!=0){
  23.                                 z = y - x[i];
  24.                                   break;
  25.                                         }
  26.                                       }
  27.                         printf("%d\n",z);
  28.                     }
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement