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

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

print(sum(wire_cost))