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
#include <iostream>
using namespace std;
int n,i,b,m;
int monety[201719];
int main()
{
	for (int i=0;i<201719; i++) monety[i]=0;
	cin>>n;
	m=0;
	for (int i=0; i<n; i++)
	{
		cin>>b;
		monety[b]=monety[b]+1;
	}
	for (int i=1; i<=201719; i++)
	{
		while (monety[i]>1)
		{
			monety[i]=monety[i]-2;
			monety[i+1]=monety[i+1]+1;
		}
	}
	for (int i=1; i<=201719; i++) if (monety[i]>0) m=i;
	cout<<m<<endl;
	
	
}