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
    for j in range(n):
            if seen[j] == True and again[j] == False:
                wire_cost[j] += 1
    if seen[num] == False:
        seen[num] = True
    elif seen[num] == True and again[num] == False:
        again[num] = True

print(sum(wire_cost))