#include<bits/stdc++.h>

#define rep(i, n) for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;

class UnionFind {
public:
    vector<int> par, rnk;

    void init(int n) {
        for (int i = 0; i < n; i++) par.push_back(i);
        rnk.resize(n, 0);
    }

    int find(int x) {
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

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

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    UnionFind UF;
    UF.init(200005);

    int ans = 0;
    rep(i, int((n+1)/2)) {
        if (i * 2 + 1 != n) {
            int x = a[i], y = a[n - i - 1];
            if (!UF.same(x, y)) {
                UF.unite(x, y);
                ans++;
            }
        }
    }

    cout << ans << endl;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
        return false;
    }
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

template<typename...args>inline bool read(int &a,args&...x){
    return (read(a),read(x...));
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

const int N=200010;

int n,a[N],ans;
bool vis[N];
vector<int> g[N];

void dfs(int x){
    if(!vis[x]) return;
    vis[x]=false;

    for(auto y:g[x]){
        dfs(y);
    }
}

signed main(){
    read(n);

    for(int i=1;i<=n;i++){
        read(a[i]);
        if(!vis[a[i]]){
            vis[a[i]]=true;
            ans++;
        }
    }

    int l=1,r=n;

    while(l<r){
        g[a[l]].push_back(a[r]);
        g[a[r]].push_back(a[l]);
        l++,r--;
    }

    for(int i=1;i<=N;i++){
        if(vis[i]){
            ans--;
            dfs(i);
        }
    }

    writeln(ans);

    return 0;
}