Code:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, cnt = 0, mn = INT_MAX,sum=0;
cin >> n;
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
sum += x;
if (x % 2 == 1) {
cnt++;
mn = min(mn, x);
}
}
if (cnt == 0) {
cout << -1;
}
else if (cnt % 2 == 1) {
cout << sum;
}
else {
cout << sum - mn;
}
return 0;
}
AC: