n=int(input())
w = list(map(int, input().split()))
c=0
for i in range(2*n):
    for j in range(i+1,2*n):
        if w[i] == w[j]:
            d = j - i
            c += d
print(c)