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-1,0,-1):
    j = rr.index(rr[i])
    d = i - j
    c2 += d    
print(c2)