//****************************Template Begins****************************//

// Header Files
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<utility>
#include<set>
#include<unordered_set>
#include<list>
#include<iterator>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<bitset>
#include<random>
#include<map>
#include<unordered_map>
#include<stdio.h>
#include<complex>
#include<math.h>
#include<cstring>
#include<chrono>
#include<string>
// Header Files End

using namespace std;
#define HARI ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define ub upper_bound
#define fo(i,a,b) for(i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define all1(v) (v).begin()+1,(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define allr1(v) (v).rbegin()+1,(v).rend()
#define sort0(v) sort(all(v))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
#define max3(a,b,c) max(max((a),(b)),(c))
#define max4(a,b,c,d) max(max((a),(b)),max((c),(d)))
#define min3(a,b,c) min(min((a),(b)),(c))
#define min4(a,b,c,d) min(min((a),(b)),min((c),(d)))
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define inf 9999999999999
const ll mod = 1e9 + 7;

ll inv(ll i) {if (i == 1) return 1; return (mod - ((mod / i) * inv(mod % i)) % mod) % mod;}

ll mod_mul(ll a, ll b) {a = a % mod; b = b % mod; return (((a * b) % mod) + mod) % mod;}

ll mod_add(ll a, ll b) {a = a % mod; b = b % mod; return (((a + b) % mod) + mod) % mod;}

ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);}

ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}

ll pwr(ll a, ll b) {a %= mod; ll res = 1; while (b > 0) {if (b & 1) res = res * a % mod; a = a * a % mod; b >>= 1;} return res;}
//****************************Template Ends*******************************//
vector<vll>adj;
vector<bool>visited;
ll ans;

void dfs(ll curr_node)
{
	visited[curr_node] = true;
	for (auto x : adj[curr_node])
	{
		if (!visited[x])
		{
			ans++;
			dfs(x);
		}
	}
}

int main() {
	HARI;
#ifndef ONLINE_JUDGE
	freopen("input.txt" , "r" , stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll t, n, i, j, temp, sum;
	string sans;
	t = 1;
	// cin >> t;
	while (t--)
	{
		sans = "NO";
		ans = temp = sum = 0;
		cin >> n;
		vll a(n + 1, 0);
		fo(i, 1, n)
		{
			cin >> a[i];
		}
		adj.resize(200001);
		visited.assign(200001, false);
		for (i = 1; i <= n / 2; i++)
		{
			if (a[i] != a[n - i + 1])
			{
				adj[a[i]].pb(a[n - i + 1]);
				adj[a[n - i + 1]].pb(a[i]);
			}
		}
		fo(i, 1, n)
		{
			if (!visited[a[i]])
			{
				dfs(a[i]);
			}
		}
		// for (auto x : adj[1])cout << x << " ";
		// cout << "\n";
		cout << ans;
	}
	return 0;
}














#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h> 
using namespace std;
 
typedef long long ll;
#define S second
#define v vector
#define dbg(x)              cout<<#x<<"="<<(x)<<endl;
#define dbg2(x,y)           cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<endl;
#define dbg3(x,y,z)         cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w)       cout<<#x<<"="<<(x)<<" "<<#y<<"="<<(y)<<" "<<#z<<"="<<(z)<<" "<<#w<<"="<<(w)<<endl;
#define mp make_pair
#define pb push_back
#define endl                '\n'
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 

int main()
{
 fast_cin();
 ll n;
 cin >> n;
 ll arr[n];
 int i;
 for (i = 0; i < n;i++)
     cin >> arr[i];
 ll mx = *max_element(arr, arr + n);
 vector<vector<int>> v1(mx + 1);
 ll sum = 0;
 ll p = n - 1;
 for (i = 0; i <p&&i!=p; i++)
 {
if(arr[i]!=arr[p])
{
    v1[arr[i]].pb(arr[p]);
    v1[arr[p]].pb(arr[i]);
    
}
p--;
}
vector<ll> vis(mx + 1, 0);

queue<ll> q1;
for (i = 1; i <= mx;i++)
{
    int c = 0;
    if (vis[i] == 0&&v1[i].size()>0)
    {
        c = 0;
        q1.push(i);
        vis[i] = 1;
        while (!q1.empty())
        {
            ll z = q1.front();
           
            for (auto x : v1[z])
            {
                if (vis[x] == 0)
                    {
q1.push(x);
vis[x] = 1;
                    }
            }
           
            q1.pop();
            c++;
}
sum += (c - 1);
    }

}
cout << sum << endl;
return 0;
}