#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		ll n;
		cin>>n;
		ll arr[n];
		vector<int> g[200000+10];
		f(i,n) {
			cin>>arr[i];
			g[arr[i]].pb(i);
		}
		int ans = 0;
		for(int i=0; i<n/2; i++) {
			if(arr[i] != arr[n-i-1]) {
				ans++;
				if(g[arr[i]].size() < g[arr[n-i-1]].size() ) {
					for(auto it : g[arr[i]]) {
						arr[it] = arr[n-i-1];
						g[arr[n-i-1]].pb(it);
					}
				}
				else {
					for(auto it : g[arr[n-i-1]]) {
						arr[it] = arr[i];
						g[arr[i]].pb(it);
					}
				}
			}
		}		
//		for(int i=0; i<n; i++) cout<<arr[i]<<" ";
		cout<<ans;
	}
 	return 0;
}

#include <bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(0), cin.tie(NULL)
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl '\n'
#define mkp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long  ull;

constexpr int INF = INT_MAX;

using namespace std;

int main(){
    fastIO;
    int N;
    cin >> N;
    ll sum = 0;
    while (N--)
    {
        ll a, b;
        cin >> a >> b;
        sum += ((b * (b + 1)) / 2) - ((a * (a + 1)) / 2) + a;
    }
    cout << sum;
    return 0;
}