#include <iostream>
using namespace std;
int main()
{
int n , E , m;
cin >> n ;
int arr[2 * n];
n = n * 2;
for (int i = 0; i < n; ++i)
{
cin >> arr[i];
}
int z = 0;
int a = n /2;
for (int i = 0; i < a; ++i)
{
E = arr[i];
int index = i;
for (int j = i + 1; j < n; ++j)
{
if (E == arr[j])
{
m = abs(index - j);
}
}
z = m + z;
}
cout << z;
return 0;
}