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