fork download
  1. #include<bits/stdc++.h>
  2. #define MOD 1000000007
  3. #define ll long long
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. std::ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10. int n;
  11. cin >> n;
  12. int a[n];
  13. ll res=0;
  14. vector<int> b;
  15. for (int i=0; i<n; ++i)
  16. {
  17. cin >> a[i];
  18. if (a[i]%2==1) b.push_back(a[i]);
  19. else res+=a[i];
  20. }
  21. sort(b.begin(), b.end());
  22. if (b.empty()) cout << 0;
  23. else
  24. {
  25. for (int i=0; i<b.size(); ++i) res+=b[i];
  26. if (res%2==0) res-=b[0];
  27. }
  28. cout << res;
  29. }
Success #stdin #stdout 0.01s 5300KB
stdin
1
2
stdout
02