#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long 
template <typename T>
void read (T &x) {
	x = 0; T f = 1;
	char ch = getchar ();
	while (ch < '0' || ch > '9') {
		if (ch == '-') f = -1;
		ch = getchar ();
	}
	while (ch >= '0' && ch <= '9') {
		x = (x << 3) + (x << 1) + ch - '0';
		ch = getchar ();
	}
	x *= f;
}
template <typename T>
void write (T x) {
	if (x < 0) {
		x = -x;
		putchar ('-');
	}
	if (x < 10) {
		putchar (x + '0');
		return;
	}
	write (x / 10);
	putchar (x % 10 + '0');
}
template <typename T>
void print (T x, char ch) {
	write (x); putchar (ch);
}
template <typename T> T Max (T x, T y) { return x > y ? x : y; }
template <typename T> T Min (T x, T y) { return x < y ? x : y; }
template <typename T> T Abs (T x) { return x > 0 ? x : -x; }

const int Maxn = 2 * 1e5;

int n;
int a[Maxn + 5];

int fa[Maxn + 5];
void MakeSet () {
    for (int i = 1; i <= Maxn; i++) {
        fa[i] = i;
    }
}
int FindSet (int x) {
    if (fa[x] != x) {
        fa[x] = FindSet (fa[x]);
    }
    return fa[x];
}
void UnionSet (int x, int y) {
    int u = FindSet (x), v = FindSet (y);
    if (u == v) return;
    fa[u] = v;
}

signed main () {
    MakeSet ();
    read (n);
    for (int i = 1; i <= n; i++) {
        read (a[i]);
    }
    int ans = 0;
    for (int i = 1, j = n; i < j; i++, j--) {
        if (FindSet (a[i]) != FindSet (a[j])) {
            UnionSet (a[i], a[j]);
            ans++;
        }
    }
    write (ans);
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define tcase int _; cin >> _; while(_--)
#define ll long long
#define endl '\n'
const int INF = 2e9;
const int MAX = 2e5+100;

void solve() {
    ll n;
    cin >> n;
    vector<int> arr(n);
    for(int &x : arr) cin >> x;

    vector<int> uf(MAX), w(MAX);
    for(int i=0; i<MAX; ++i) uf[i] = i, w[i] = 1;

    auto find = [&](auto &&self, int i) -> int {
        return i == uf[i] ? i : uf[i] = self(self, uf[i]);
    };

    auto join = [&](int i, int j) -> void {
        i = find(find, i);
        j = find(find, j);
        if(i == j) return;
        if(w[i] > w[j]) {
            uf[j] = i;
            w[i] += w[j];
        } else {
            uf[i] = j;
            w[j] += w[i];
        }
    };

    int answer = 0;
    for(int i=0; i<n/2; ++i) {
        if(find(find, arr[i]) != find(find, arr[n-i-1])) {
            answer++;
            join(arr[i], arr[n-i-1]);
        }
    }
 
    cout << answer << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();

    return 0;
}	