n = int(input()) A = list(map(int, input().split())) ans = 0 for t in range(1, 31): B = [a - t for a in A] tot = 0 cnt = {} for b in B: cnt[tot] = cnt.get(tot, 0) + 1 if b == 0: ans += cnt.get(tot, 0) tot += b print(n * (n + 1) // 2 - ans + 1)