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
#include <iostream>
#include <array>
const int MAX_VAL = 1000000;
const int MAX_N = 1000005;

std::array<bool, MAX_VAL> coins;

int n;

int max_unit = -1;

void ins(int t) {

    for (int i = t; true; i++) {    
        coins [i] = !coins[i];

        if (coins[i] == true) {
            max_unit = std::max(max_unit, i);
            break;
        }
    }

}


void solve() {
    std::cin >> n;

    for (int i = 0; i < n; i ++) {
        int t;
        std::cin >> t;

        ins(t);
    }

    std::cout << max_unit << std::endl;
}

int main () {
    std::ios_base::sync_with_stdio(false);
    solve ();
    return 0;
}