#include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector H(N); for(auto &h : H) cin >> h; sort(H.begin(),H.end()); long long answer = 0,pos = 0,p = 1,inf = 2e18; while(pos < N){ if(H.at(pos) <= 0) break; answer++; if(H.at(pos) > p) H.back() -= p; else pos++; p = min(p*2,inf); } cout << answer << endl; }