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 = {0: 1} for b in B: if b == 0: ans += cnt.get(tot, 0) tot += b cnt[tot] = cnt.get(tot, 0) + 1 print(n * (n + 1) // 2 - ans + 1)