// Template
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <tuple>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <array>
#include <cassert>
#include <cmath>
#define rep_override(x, y, z, name, ...) name
#define rep2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep3(i, l, r) for (int i = (int)(l); i < (int)(r); ++i)
#define rep(...) rep_override(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll infll = 3003003003003003003LL;
template <typename T>
inline bool chmin(T &x, const T &y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T> 
inline bool chmax(T &x, const T &y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &element : vec) is >> element;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    for (int i = 0, vec_len = (int)vec.size(); i < vec_len; ++i) {
        os << vec[i] << (i + 1 == vec_len ? "" : " ");
    }
    return os;
}
struct IOSET {
    IOSET() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
    }
} ioset;

// Main
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    cin >> a;
    
    constexpr int mx = 200001;
    vector<vector<int>> g(mx);
    rep(i, n) {
        if (a[i] != a[n - 1 - i]) {
            g[a[i]].push_back(a[n - 1 - i]);
        }
    }
    
    int ans = 0;
    vector<int> checked(mx, 0);
    rep(i, mx) {
        if (g[i].empty()) continue;
        if (checked[i]) continue;
        queue<int> q;
        q.push(i);
        int sz = 0;
        checked[i] = 1;
        ++sz;
        while (!q.empty()) {
            int j = q.front();
            q.pop();
            for (int k : g[j]) {
                if (!checked[k]) {
                    checked[k] = 1;
                    ++sz;
                    q.push(k);
                }
            }
        }
        ans += sz - 1;
    }
    cout << ans << '\n';
}

#include <bits/stdc++.h>
#define SZ(x) (int)x.size()
#define ll long long
#define pb push_back
using namespace std;

const int N = 200005;
int n;
int a[N], f[N];

int find(int x) {
    return x == f[x] ? x : f[x] = find(f[x]);
}

int main() {
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for(int i = 0; i < N; ++i) f[i] = i;
    for(int i = 0; i < n / 2; ++i) {
        int u = find(a[i]), v = find(a[n - 1 - i]);
        if (u != v) {
            f[u] = v;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}