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

int main()
{
    int n;
    cin >> n;
    
    vector<int> houses(2*n);
    for (int i = 0; i < 2*n; ++i)
    {
        cin >> houses[i];
    }
    
    int totalLength = 0;
    for (int i = 0; i < 2*n; ++i)
    {
        if (houses[i] == -1)
        {
            continue;
        }
        
        for (int j = i+1; j < 2*n; ++j)
        {
            if (houses[j] == -1)
            {
                continue;
            }
            
            else if (houses[i] == houses[j])
            {
                totalLength += j - i;
                houses[i] = -1;
                houses[j] = -1;
                break;
            }
        }
    }
    
    cout << totalLength << endl;

    return 0;
}