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):
    if c1 == n:
        break
    for j in range(2*n-1,i,-1):
        if rr[i] == rr[j]:
            d = j - i 
            c2 += d
            c1 += 1
print(c2)