#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

#define x first
#define y second
#define NMAX 100006

int n, position[NMAX], f[NMAX], AIB[NMAX], v[NMAX], answer;

void update(int poz,int val)
{
    for(;poz<=n;poz+=poz^(poz-1)&poz)
        AIB[poz]+=val;
}
 
int query(int poz)
{
    int s=0;
    for(;poz;poz-=poz^(poz-1)&poz)
        s+=AIB[poz];
    return s;
}

int main (){

    scanf("%d",&n);    
    for(int i = 1; i <= 2 * n; i++){
        scanf("%d",&v[i]);
    }
    int nth = 0, active = 0;
    for(int i = 1; i <= 2 * n; i++){
        if(!f[v[i]]){
            position[v[i]] = ++nth;
            update(nth, +1);
            f[v[i]] = 1;
            active++;
        }
        else{
            update(position[v[i]], -1);
            active--;
            answer += active - query(position[v[i]]);
        }
    }
    
    printf("%d\n", answer);
    
    return 0;
}