#include <iostream>
#include <vector>
#include <map>
using namespace std;
int minOperations(vector<int>& arr) {
map<int, long long> freq;
for (int x : arr) {
freq[x]++;
}
int operations = 0;
for (auto it = freq.begin(); it != freq.end(); ++it) {
int exp = it->first;
long long count = it->second;
if (count >= 2) {
freq[exp + 1] += count / 2;
}
if (count % 2 != 0) {
operations++;
}
}
return operations;
}