#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,N;
  cin >> n;
  N = pow(2,n);
  vector<int> vec(N);
  vector<int> vec2(N);
  for(int i = 0;i<N;i++){
    int A;
    cin >> A;
    vec.at(i) = A;
  }
  vec2 = vec;
  while(vec.size()!=2){
    for(int i = 0;i<N/2;i++){
      if(vec.at(i)<=vec.at(i+1)){
        vec.erase(vec.begin()+i);
      }
      else{
        vec.erase(vec.begin()+i+1);
      }
    }
    N /= 2;
  }
  int zyun = min(vec.at(0),vec.at(1));
  for(int i = 0;i<pow(2,n);i++){
    if(vec2.at(i)==zyun){
      cout << i+1;
      break;
    }
  }
}
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 3e5;
class union_find{
  int n;
  vector<int> par,rk,size;
  public:
  union_find(int max_n){
    n = max_n+1;
    for(int i=0;i<=n;i++){
      par.emplace_back(i);
      rk.emplace_back(0);
      size.emplace_back(1);
    }
  }
  int root(int x){
    vector<int> nodes;
    while(x!=par[x]){
      nodes.emplace_back(x);
      x = par[x];
    }
    for(auto v:nodes){
      par[v] = x;
    }
    return x;
  }
  void unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y) return;
    if(rk[x]<rk[y]){
      par[x] = y;
      size[y] += size[x];
    }else{
      par[y] = x;
      if(rk[x]==rk[y]) rk[x]++;
      size[x] += size[y];
    }
  }
  bool same(int x,int y){
    return root(x)==root(y);
  }
  int treesize(int x){
    return size[root(x)];
  }
};
signed main(){
  init_io();
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  union_find uf(MAX);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if(!uf.same(a[i], a[n-1-i])) {
      uf.unite(a[i], a[n-1-i]);
      ans++;
    }
  }
  cout << ans << endl;
}
