#include <iostream>

using namespace std;

int main()
{ 
	long long n , E , m;
	cin >> n ;
	long long arr[2 * n];
	n = n * 2;
	for (int i = 0; i < n; ++i)
	{
		cin >> arr[i];
	}
	int z = 0;
	for (int i = 0; i < n; ++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;
}