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
#include<bits/stdc++.h>

using namespace std;

int n,i,j;
priority_queue<int> q;

int main()
{
    scanf("%d", &n);
    for(i = 0;i<n;++i)
    {
        scanf("%d", &j);
        q.push(-j);
    }
    j = q.top();
    q.pop();
    while(!q.empty())
    {
        if(q.top()==j)
        {
            q.push(j-1);
            q.pop();
        }
        j = q.top();
        q.pop();
    }
    printf("%d\n", -j);
    return 0;
}