#include <iostream>
using namespace std;
int main()
{
int n; cin >> n;
int arr[2*n];
int metr = 0;
for ( int i = 0 ; i < n*2 ; i ++ )
{
cin >> arr[i];
for ( int j = 0 ; j < i ; j ++ )
{
if ( i > 0 && arr[i] == arr[j] )
{
metr += abs(i - j);
}
}
}
cout << metr;
return 0;
}