#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector a(n); for(auto &&v : a) cin >> v; sort(a.begin(), a.end()); ll p = 1; int ans = 0, cnt = 0; constexpr ll th = 1'000'000'000'000'000'000ll; while(p < th && cnt < n){ bool flg = false; for(int i = 0; i < n; i++){ if(a[i] == 0) continue; if(a[i] <= p){ p = min(2 * p, th); ans++; cnt++; a[i] = 0; flg = true; break; } } if(flg) continue; int pos = 0, mn = -61; for(int i = 0; i < n; i++){ if(a[i] == 0) continue; int bcnt = __builtin_popcountll(a[i]) - __builtin_popcountll(a[i] - p); if(bcnt > mn){ mn = bcnt; pos = i; } } a[pos] -= p; ans++; p = min(2 * p, th); } for(int i = 0; i < n; i++){ if(a[i] >= 1) ans++; } cout << ans << '\n'; }