1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<int> money;
  for (int i = 0; i< n; i++){
     int tmp;
     cin >> tmp;
     money.push_back(tmp);
  }
  int res = 0;
  int minn = -1;
pair<int,int> ile = make_pair(0,-1);
  for (int i = 0; i< n; i++){
 //   cout<<res<<" ";
    if (money[i]%2==0) res+= money[i];
    else {
      if (ile.first == 1) {
        res = res + money[i] + ile.second;
        ile.first = 0;
        if (minn > money[i]) {
          minn = money[i];
        }
      }
      else {
          ile.first = 1;
          ile.second = money[i];
        if (minn == -1) minn = money[i];
        if (minn < money[i]) {
          res=res-minn+money[i];
          ile.second=minn;
        }
      }
    }
  }
  if (res==0) cout<<"NIESTETY\n";
  else cout<<res<<"\n";
}