n=int(input())
rr = list(map(int, input().split()))
ri = rr
rr.reverse()
#print(ri)
c1=0
c2=0





for i in range(2*n):
    j = rr.index(ri[i])
    d = (2* n) - i - j -1
    c2 += d    
print(c2)