#include<bits//stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
//type define....
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int u_int;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> v_i;
typedef vector<ll> v_ll;
typedef vector<pair<int,int>> v_pii;
typedef vector<pair<ll,ll>> v_pll;
typedef set<int> s_i;
typedef set<ll> s_ll;
typedef map<int,int> map_ii;
typedef map<ll,ll> map_ll;
typedef priority_queue<int> max_heap_i;
typedef priority_queue<int,vector<int>,greater<int>> min_heap_i;
typedef priority_queue<ll> max_heap_ll;
typedef priority_queue<ll,vector<ll>,greater<ll>> min_heap_ll;
typedef tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> pbds_set;
//END OF TYPE DEFINE

//Macros define
#define F first
#define S second
#define PB push_back
#define IN insert
#define RIL(i,a,b) for(int i=a;i<b;i++)
#define RIL_K(i,a,b,k) for(int i=a;i<b;i+=k)
#define RDL(i,a,b) for(int i=a;i>=b;i--)
#define RDL_K(i,a,b,k) for(int i=a;i>=b;i-=k)
#define all(v) v.begin(),v.end()
#define MAX(a,b,c) (max(a,max(b,c)))
#define MIN(a,b,c) (min(a,min(b,c)))
//End of Macros
v_i v;
int ans=-1;
int n;
int fun(int lo,int hi)
{
    if(hi==lo+1)
    {
        return (v[lo]>v[hi]? lo:hi);
    }
    int mid=lo+(hi-lo)/2;
    int left=fun(lo,mid);
    int right=fun(mid+1,hi);
    if((hi-lo)==((1<<n)-1))
    {
        ans=((v[left]>v[right])? right:left);
    }
    return ((v[left]>v[right])? left:right);
}
void solve()
{
    //int n;
    cin>>n;
    v.resize(1<<n);
    RIL(i,0,1<<n) cin>>v[i];
    int idx1=0;
    RIL(i,0,1<<(n-1))
    {
        if(v[i]>v[idx1])
        {
            idx1=i;
        }
    }
    int idx2=1<<(n-1);
    RIL(i,1<<(n-1),1<<n)
    {
        if(v[i]>v[idx2])
        {
            idx2=i;
        }
    }
    cout<<(v[idx1]<v[idx2]? idx1:idx2)+1<<endl;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    RIL(i,0,t)
    {
        solve();
    }
}

#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using P = pair<long long, long long>;

const long long INF = 1000000000000000000;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> data(200000, vector<int>(0));
  rep(i, 0, n) cin >> a.at(i);
  rep(i, 0, n/2) {
    if (a.at(i) != a.at(n-1-i)) {
      data.at(a.at(i)-1).push_back(a.at(n-1-i)-1);
      data.at(a.at(n-1-i)-1).push_back(a.at(i)-1);
    }
  }
  int ans = 0;
  vector<bool> seen(200000, false);
  queue<int> que;
  rep(i, 0, 200000) {
    if (!seen.at(i)) {
      que.push(i);
      seen.at(i) = true;
    }
    while (!que.empty()) {
      int x = que.front();
      que.pop();
      for (int y : data.at(x)) {
        if (!seen.at(y)) {
          seen.at(y) = true;
          que.push(y);
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
}