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

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int n, ans = 0;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; ++i) cin >> a[i];
    UnionFind uf(200010);
    for(int i = 0; i < n/2; ++i) {
        if(a[i] != a[n-i-1]) {
            uf.merge(a[i], a[n-i-1]);
        } 
    }
    
    for(int i = 0; i < 200010; ++i) {
        if(uf.root(i) == i) ans += uf.size(i) - 1;
    }

    cout << ans << '\n';

    return 0;
}

#include<bits/stdc++.h>
#define pb push_back
#define pdd pair<ld, ld>
#define int long long
#define ff first
#define pii pair<int,int>
#define ss second
#define pp make_pair
#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define PI 3.1415926535 
#define mst(v, x) memset(v, x, sizeof v);
#define all(v) v.begin(), v.end()
#define dpq priority_queue<int>
#define ipq priority_queue<int, vector<int>, greater<int>>
#define setbits(x)          __builtin_popcountll(x)
using namespace std;
void IOS(){ios::sync_with_stdio(false); cout.precision(10); cout << fixed;}
const int MOD = 1e9 + 7;
#define INF 2000000000
const int mx=1e5+1;
int dx[] = {0,0,1,-1}, dy[] = {1,-1,0,0};

int i;
vector<bool>fl(200005, false);
int cnt;
using Graph = vector<vector<int>>;
Graph g(200003);

void dfs(int x){
	if(!fl[x])return;
	fl[x] = 0;
	for(auto & nx : g[x])dfs(nx);
}

int32_t main(){
	IOS();
	int n;
	cnt = 0;
	cin>>n;
	
	vector<int>ar(n);
	rep(i,n){
		cin>>ar[i];
		if(!fl[ar[i]])fl[ar[i]] = 1, cnt++;
	}
	int i = 0, j=n-1;
	while(i<j){
		g[ar[i]].pb(ar[j]);
		g[ar[j]].pb(ar[i]);
		i++; j--;	
	}
	for(int i=0; i<=200002; i++){
		if(fl[i]){
			cnt--;
			dfs(i);
		}
	}
	cout<<cnt<<"\n";
	return 0;
}
