n = int(input())
inp = list(map(int, input().split()))
wire_cost = [0] * n
seen = [False] * n
again = [False] * n

for i in range(2*n):
    num = inp[i]-1
    if seen[num] == False:
        seen[num] = True
    elif seen[num] == True and again[num] == False:
        for j in range(len(seen)):
            if seen[j] == True:
                wire_cost[j] += 1
                if seen[num] == True:
                    again[num] = True
        
    

print(sum(wire_cost))