#include<bits/stdc++.h>
using namespace std;
int n,a[200005],parent[200005],s=0;
int findparent(int x)
{
    if (x==parent[x]) return x;
     return parent[x]=findparent(parent[x]);
}
void Union(int u,int v)
{
    int p=findparent(u);//find parents of u
    int q=findparent(v);//find parents of v;
    if(p!=q)parent[q]=p;
}
int main()
{
    cin>>n;
    for (int i=1; i<=n; i++) cin>>a[i],parent[a[i]]=a[i];
    for (int i=1; i<=n; i++)
    {
        int x=findparent(a[i]);
        int y=findparent(a[n-i+1]);
        if (x!=y)
        {
            s++;
            Union(x,y);
        }
    }
    cout<<s<<endl;
}

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i)
#define rep(i, n) drep(i, 0, n - 1)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define fi first
#define se second

const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll INF = 1e18;
const ll n_max = 2e5 + 1;

vector<vector<ll>> G(n_max);
vector<bool> check(n_max, false);
ll dfs(ll v){
    if(check[v]) return 0;
    check[v] = true;
    ll ret = 0;
    for(ll u : G[v]){
        if(check[u]) continue;
        ret += dfs(u) + 1;
    }
    return ret;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    for(ll i = 0; i <= (n-1)/2; i++){
        if(a[i] != a[n-1-i]){
            G[a[i]].pb(a[n-1-i]);
            G[a[n-1-i]].pb(a[i]);
        }
    }
    ll ans = 0;
    drep(i, 1, n_max-1){
        if(check[i]) continue;
        ans += dfs(i);
    }
    cout << ans << endl;
}