//代码如下
#include<bits/stdc++.h>
using namespace std;
int a[25][10005];
int main(void)
{
int ans=-1,ansn;
int n;
scanf("%d",&n);
int depth=log2(n+1);
if(n+1==pow(2,depth)) {
for(int i=1;i<=depth;i++)
for(int j=1;j<=pow(2,i-1);j++)
scanf("%d",&a[i][j]);
for(int i=1;i<=depth;i++){
int sum=0;
for(int j=1;j<=pow(2,i-1);j++)
sum+=a[i][j];
if(sum>ans){
ans=sum;
ansn=i;
}
}
}
else{
for(int i=1;i<=depth;i++)
for(int j=1;j<=pow(2,i-1);j++)
scanf("%d",&a[i][j]);
for(int j=1;j<=n+1-pow(2,depth);j++)
scanf("%d",&a[depth+1][j]);
for(int i=1;i<=depth;i++){
int sum=0;
for(int j=1;j<=pow(2,i-1);j++)
sum+=a[i][j];
if(sum>ans){
ans=sum;
ansn=i;
}
}
int sum=0;
for(int j=1;j<=n+1-pow(2,depth);j++)
sum+=a[depth+1][j];
if(sum>ans){
ans=sum;
ansn=depth+1;
}
}
printf("%d",ansn);
return 0;
}