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
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include <bits/stdc++.h>

#define REP(i,x) for(uint32 i = 0 ; i < (x) ; i++)

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define print(x) cout << #x << " = " << x << endl
#define debug(x) x
#else
#define print(x)
#define debug(x)
#endif

#define hash_map      unordered_map
#define hash_multimap unordered_multimap
#define hash_set      unordered_set
#define hash_multiset unordered_multiset

using namespace std;

typedef short int int16;
typedef unsigned short int uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;

typedef pair <int, int> PII;
typedef pair <uint32, uint32> PUU;
typedef pair <uint32, int> PUI;
typedef pair <int, uint32> PIU;
typedef pair <int64, int64> PLL;
typedef pair <int64, int> PLI;
typedef pair <int, int64> PIL;
typedef pair <int, int16> PIS;
typedef pair <int16, int> PSI;

static const int UNDEF = -1;

class Application
{
public:
    inline void Run();
private:
    // Methods
    inline void LoadData();
    inline void Solve();
    
    // Fields

};

int main()
{
    ios_base::sync_with_stdio(false);
    Application app;
    app.Run();
}

inline void Application::LoadData()
{
    
}

inline void Application::Solve()
{
    int size;
    cin >> size;
    
    vector <int> nominals;
    nominals.assign(1001, 0);
    
    int bucket;
    REP(i, size)
    {
        cin >> bucket;
        ++ nominals[bucket];
    }
    
            
    bucket = UNDEF;
    int64 result = 0;
    
    for(int i = 1000; i > 0; --i)
    { 
        if(i % 2 == 0)
            result += ((int64)nominals[i] * i);  
        else if(nominals[i] > 0)
        {
            if(bucket != UNDEF)
            {
                result += bucket;
                result += i;
                
                nominals[i] -= 1;
                bucket = UNDEF;
            }
            
            if(nominals[i] % 2 == 0)
            {
                 result += ((int64)nominals[i] * i);
            }
            else
            {
                 result += (((int64)nominals[i] - 1) * (int64)i);
                 bucket = i;
            }
        }
    }
    
    
    if(result != 0)
        cout << result << "\n";
    else
        cout << "NIESTETY\n";
}

inline void Application::Run()
{
    LoadData();
    Solve();
}