#include <iostream>
using namespace std;
const int maxn=2e5;
const int maxa=2e5+1;
int N;
int A[maxn];
int rt[maxa];
int fndrt(int a){
	return rt[a]=(a==rt[a])?a:fndrt(rt[a]);
}
int main() {
	while(cin>>N){
		//higha will minimize the amount of array being updated.
		int higha=1;
		for(int i=0;i<N;i++){
			cin>>A[i];
			higha=max(higha,A[i]);
		}
		//Set all numbers to represent themselves
		for(int i=0;i<higha;i++){
			rt[i]=i;
		}
		//P and Q are theh numbers that A[i] or A[j] represents
		//basically we changed all A[i] or A[j] to P or Q
		int P,Q;
		int operations=0;
		for(int i=0,j=N-1;i<j;i++,j--){
			P=fndrt(A[i]);
			Q=fndrt(A[j]);
			//If they are not the same number,
			//then change the first number to represent the second number
			if(P!=Q){
				//Add one more operation
				operations++;
				//Change the representation of the first number to the second number
				rt[P]=Q;
			}
		}
		cout<<operations<<'\n';
	}
}
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define fl(n) for(int i=0;i<n;i++)
#define flj(n) for(int j=0;j<n;j++)
#define flo(n) for(int i=1;i<=n;i++)
#define mii map<int,int>
#define mci map<char,int>
#define V vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define pp pair<int,int>
#define ff first
#define ss second
#define S set<int>
#define all(v) v.begin(),v.end()
#define gr greater<int>()
#define show2(a, b) cout<<a<<' '<<b<<endl;
#define show3(a, b, c) cout<<a<<' '<<b<<' '<<c<<endl;
const long long mod=1000000007;
const int N=2e5+5;
const long double PI=3.14159265358;
vector<vector<int>> adj;
bool vis[N];

// main code;
int c;
map<int,vector<int>> mp;
map<int,bool> visited;
void dfs(int j){
	visited[j]=true;
	c++;
	for(auto u:mp[j]){
		if(!visited[u]) dfs(u);
	}
}
int32_t main(){
    int t=1;
    //cin>>t;
	while(t--){
    int n;
    cin>>n;
    int a[n];
    fl(n){
    	cin>>a[i];
    	visited[a[i]]=false;
	}
    for(int i=0;i<n/2;i++){
    	mp[a[i]].pb(a[n-i-1]);
    	mp[a[n-i-1]].pb(a[i]);
	}
    int ans=0;
    for(auto it:mp){
    	if(!visited[it.ff]){
    		c=0;
    		dfs(it.ff);
    		ans+=max(0ll,c-1);
		}
	}
	cout<<ans;
    
}
	return 0;
	}