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