递推
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int w[N];
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
scanf("%d",&w[i]);
}
double E;
for(int i=n;i>0;i--){
E = (w[i]+E)/2;
}
E = ceil(E);
cout<<E<<endl;
}