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
#include <iostream>

using namespace std;

long long counter[1500001];

int main()
{	
	int n;
	int number;
	cin >> n;
	for (int i = 0; i < 1500001; i++) {
		counter[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> number;
		counter[number] += 1;
	}
	int idx;
	for (idx = 0; idx < 1500000; idx++) {
		counter[idx + 1] += (counter[idx] / 2);
		if (idx > 201718 && counter[idx + 1] == 0) break;
	}
	for (int i = idx; i >= 0; i++) {
		if (counter[i] > 0) {
			cout << n;
			return 0;
		}
	}
	cout << 0;
    return 0;
}