#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int arr[n * 2];
    for (int i = 0; i < n * 2; i++)
    {
        cin >> arr[i];
    }

    int chortke[100000];
    for (int i = 0; i < 100000; i++)
    {
        chortke[i] = 0;
    }

    for (int i = 0; i < n * 2; i++)
    {
        for (int j = i + 1; j < n * 2; j++)
        {
            if (arr[i] == arr[j])
            {
                chortke[arr[i]] = j - i;
            }
        }
    }

    long long sum = 0;
    for (int i = 0; i < 100000; i++)
    {
        sum += chortke[i];
    }
    cout << sum;

    return 0;
}