#include <iostream>
#include <cmath>
using namespace std;

int main()
{

    int n;
    cin >> n;

    int a[2 * n];

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

    int sum = 0;
    for (int i = 0; i < 2 * n; i++)
    {
        for (int j = (2 * n) - 1; j >= 0; j--)
        {
            if (a[i] == a[j] && i < j)
            {
                sum += (j - i);
            }
        }
    }
    cout << sum;

    return 0;
}