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 <cstdio>
const int CNUM = 201800;
int coins[CNUM];

int main()
{
	int n = 0;
	scanf("%d", &n);
	int a = 0;
	while(n-- > 0)
	{
		scanf("%d", &a);
		coins[a]++;
	}

	int max_coin = 0;
	for (int i = 0; i < CNUM - 1; i++)
	{
		coins[i + 1] += coins[i] / 2;
		if (coins[i + 1] > 0)
		{
			max_coin = i + 1;
		}
	}

	printf("%d\n", max_coin);
}