#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;

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


    int x = 0;
    int keeper = 0;
    int sum = 0;
    for ( int i = 1 ; i < n + 1 ; i ++ )
    {
        for ( int z = 0 ; z < 2 * n ; z ++ )
        {
            if ( i == arr[z] )
            {
                if ( x == 0 )
                {
                    keeper = z;
                    x ++;
                }

                else
                {
                    sum += z - keeper;
                }
            }
        }

        x = 0;
    }

    cout << sum;
   

    return 0;
}