#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_N 200001
int par[MAX_N]; //親
int rnk[MAX_N]; //木の深さ
int siz[MAX_N]; //木のサイズ
typedef long long ll;

//n要素で初期化
void init(){
    REP(i,MAX_N){
        par[i]=i;
        rnk[i]=0;
        siz[i]=1;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rnk[x]<rnk[y]){
        par[x]=y;
        siz[y]+=siz[x];
    }else{
        par[y]=x;
        siz[x]+=siz[y];
        if(rnk[x]==rnk[y]) rnk[x]++;
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x)==find(y);
}

//連結成分の個数
int union_num(int n){
    int rtn=0;
    REP(i,n) if(i==find(i)) rtn++;
    return rtn;
}

int main(){
    int n;cin>>n;
    int ans=0;
    vector<int> x(n,0);
    set<int> se;
    init();
    REP(i,n){
      cin>>x.at(i);
      se.insert(x.at(i));
    }
    REP(i,n) unite(x.at(i),x.at(n-i-1));
    for(auto p:se) if(p==find(p)) ans+=siz[p]-1;
    //REP(i,n) if(x.at(i)==find(x.at(i))) ans+=siz[x.at(i)]-1; 
    //for(auto p:se)  cout<<p<<" "<<find(p)<<" "<<siz[p]<<endl;
    cout<<ans<<endl;
}
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int f=1,r=0;char c=getchar();
	while(!isdigit(c))f^=c=='-',c=getchar();
	while(isdigit(c))r=(r<<1)+(r<<3)+(c^48),c=getchar();
	return f?r:-r;
}
int main(){
	cout<<max(read(),0);
	return 0;	
}