n = int(input())
buildings = input().split()
buildings = [int(i) for i in buildings]
wires = 0
for i in range(len(buildings)):
    first = buildings[i]
    for j in range(i + 1, len(buildings)):
        second = buildings[j]
        if second == first:
            wires = wires + j - i
print(wires)