#include "bits/stdc++.h"
using namespace std;

#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i = a; i <= n; i++)
#define per(i,a,n) for(int i = a; i >= n; i--)
#define vi vector<int>
#define pb push_back
#define itr(i,v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
#define kill(x) {cout << x << "\n"; return;}
constexpr int mx = 2e5 + 10;
int fa[mx],sz[mx];
int gf(int x) { return fa[x]==x?x:fa[x]=gf(fa[x]); }

void merge(int x,int y) {
	x = gf(x); y = gf(y);
	if(x!=y) sz[x] += sz[y],fa[y]=x,sz[y] = 0;
}
void solve(){
	iota(fa,fa+mx,0);
	fill(sz,sz+mx,1);

	int n; cin >> n;
	vi v(n); fr(i,n) cin >> v[i];
	int ans = 0;
	fr(i,n/2) merge(v[i],v[n-1-i]);
	fr(i,mx) if(sz[i]) ans += sz[i] - 1;
	kill(ans);




}

int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   // int tst; cin >> tst; while(tst--)
   {
   	solve();
   }
}
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("O3")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T &b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T &b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

bool ok(int n){
    for(int p : {10, 8}) {
        int cn = n;
        while (cn) {
            if (cn % p == 7) return false;
            cn /= p;
        }
    }
    return true;
}

template <class T> class BIT {
    //T has operator "+=" and can be initialized with 0.
    unsigned int n;
    vector<T> bitree;
public:
    BIT(unsigned long _n) : bitree(_n + 1, 0) {
        n = _n;
    }

    void add(int id, T x) {
        ++id;
        while (id <= n) {
            bitree[id] += x;
            id += id & -id;
        }
    }

    T sum(int id) {
        ++id;
        T temp(0);
        while (id > 0) {
            temp += bitree[id];
            id -= id & -id;
        }
        return temp;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>H>>W>>M;
    vec up(W, H), left(H, W);
    rep(i, M){
        ll x, y; cin>>x>>y;
        --x; --y;
        chmin(up[y], x);
        chmin(left[x], y);
    }
    ll res = 0;
    rep(i, up[0]) res += left[i];
    rep(i, left[0]) res += up[i];
    //cout<<res<<endl;
    BIT<ll> bit(W + 1);
    rep(i, left[0]) bit.add(i, 1);
    priority_queue<P, vector<P>, greater<> > pque;
    rep(i, left[0]) pque.emplace(up[i], i);
    rep(i, up[0]){
        while(!pque.empty()){
            P p = pque.top();
            ll hei = p.first, id = p.second;
            if(hei > i) break;
            pque.pop();
            bit.add(id, -1);
        }
        res -= bit.sum(left[i] - 1);
        //rep(j, W) cout<<bit.sum(j) - (j ? bit.sum(j-1) : 0)<<" \n"[j==W - 1];
        //cout<<bit.sum(left[i] - 1)<<endl;
    }
    cout<<res<<endl;
}
