#include <iostream>
using namespace std;
int main()
{
int n, counter = 0;
cin >> n;
int arr[n * 2];
int len = sizeof(arr) / sizeof(arr[0]);
for (int i = 0; i < len; i++)
{
cin >> arr[i];
}
for (int i = 0; i < len; i++)
{
for (int j = i + 1; j <= len; j++)
{
if (arr[j] == arr[i])
{
counter += j - i;
break;
}
}
}
cout << counter;
return 0;
}