import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
TreeMap<Long, Long> num_count = new TreeMap<>();
StringTokenizer st = new StringTokenizer(br.readLine());
for (int i=0; i<N; i++) {
long a =Long.parseLong(st.nextToken());
num_count.put(a, num_count.getOrDefault(a, 0L) + 1);
}
int ans = 0;
while(!num_count.isEmpty()) {
long currentSize = num_count.firstKey();
long count = num_count.remove(currentSize);
if (count >= 2) {
long nextSize = currentSize*2;
long combinedCount = count / 2;
num_count.put(nextSize, num_count.getOrDefault(nextSize, 0L) + combinedCount);
if (count % 2 != 0) ans ++;
}
else if (count == 1) ans ++;
}
System.out.println(ans);
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: