#include <bits/stdc++.h>

using namespace std;

#define int long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n";
#define rep(i, a, b) for (int i=a; i<b; i++)
#define pre(i, a, b) for (int i=a; i>=b; i--)

const int MAX_N = 2e5+5;
const int MOD = 1e9 + 7;
const int INF = 1e9;

#define pb push_back
#define fi first
#define se second
#define sz size()
#define bg begin()
#define ed end()
#define bk back()
#define pii pair<int, int>
#define mp map<int, int>
#define vi vector<int>
#define vvi vector<vector<int>> 
#define si set<int>

/* #define deb(...) logger(#__VA_ARGS__, __VA_ARGS__)
template<typename ...Args>
void logger(string vars, Args&&... values) {
    cout << vars << " = ";
    string delim = "";
    (..., (cout << delim << values, delim = ", "));
} */

int ans = 0;
int parent[MAX_N], siz[MAX_N];

int findParent(int i){
	if(parent[parent[i]]!=parent[i]){
		parent[i] = findParent(parent[i]);
	}

	return parent[i];
}

void unionNodes(int a, int b){
	int parent_a = findParent(a);
	int parent_b = findParent(b);

	if(parent_b==parent_a){
		return;
	}

	ans++;

	if(siz[parent_a]>=siz[parent_b]){
		swap(parent_a,parent_b);
	}

	siz[parent_b] += siz[parent_a];

	parent[parent_a] = parent_b;
	return;
}

void cleardsu(int n){
	rep(i,1,n+1){
		parent[i] = i;
		siz[i] = 1;
	}
}

void solve() {
	int n; cin>>n;

	cleardsu(MAX_N-2);

	vi a(n);

	rep(i,0,n) cin>>a[i];

	rep(i,0,n){
		int j = n - 1 - i;
		unionNodes(a[i],a[j]); 
	}

	cout<<ans;
}

signed main() {
    fast

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

    cout.precision(10);
    cout<<fixed;

    int t = 1;
    // cin >> t;

    for (int i = 1; i <= t; i++) {
        // cout << "Case #" << i  << ": ";
        solve();
    }
}

        

#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

struct UnionFind {
    vector<int> par;
    UnionFind (int n) : par(n, -1){}
    int root(int x){
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y){
        x = root(x), y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x,y);
        par[x] += par[y]; 
        par[y] = x;
        return true;
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    int size(int x) {
        return -par[root(x)];
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    UnionFind uf(200005);
    for(int i = 0; i < n; i++) uf.unite(a[i], a[n-1-i]);
    int ans = 0;
    for(int i = 0; i < 200005; i++) if(uf.root(i) == i) ans += uf.size(i)-1;
    cout << ans << endl;
    return 0;
}