#include<bits/stdc++.h>
using namespace std;
typedef struct{
long long high;
int number;
}bamboo;
struct cmp{
bool operator()(bamboo a,bamboo b){
if(a.high==b.high)
return a.number<b.number;
return a.high<b.high;
}
};
void print(priority_queue<bamboo,vector<bamboo>,cmp> pq){
while (!pq.empty()) {
bamboo e = pq.top();
pq.pop();
cout<<e.number<<" ";
}
cout<<endl;
}
int main(){
int n; cin>>n;
bamboo temp;
priority_queue<bamboo,vector<bamboo>,cmp> pq;
for(int i=0;i<n;++i){
scanf("%lld",&temp.high);
temp.number=i;
if(temp.high>1) pq.push(temp);
}
long long ans=0;
while(!pq.empty()){
temp=pq.top();pq.pop();
while(!pq.empty() && temp.high==pq.top().high && abs(temp.number-pq.top().number)==1){
temp=pq.top();
pq.pop();
}
temp.high=sqrtl((temp.high/2)+1);
if(temp.high>1) pq.push(temp);
ans++;
}
cout<<ans;
return 0;
}