n = int(input())
a = list(map(int, input().split()))

sums = [0]
for i in range(n):
    sums.append(sums[i] + a[i])
def comb2(n):
  return (n*(n-1)) // 2


res = 0
for i in counts:
  res += comb2(counts[i])
print(res)
