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

ans = n * (n + 1) // 2

for t in range(1, 31):
    B = [a - t for a in A]

    cnt = {}
    tot = 0
    cnt[0] = 1
    for b in B:
        tot += b
        ans -= cnt.get(tot, 0)
        cnt[tot] = cnt.get(tot, 0) + 1

    cnt = {}
    tot = 0
    for b in B:
        if b != 0:
            cnt[tot] = cnt.get(tot, 0) + 1
        tot += b
        if b != 0:
            ans += cnt.get(tot, 0)

ans += 1
print(ans)