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 = (2* n) - i - j -1 c2 += d print(c2)