#!/usr/bin/env python3

from collections import defaultdict

N = int(input())
A = map(int, input().split())

d = defaultdict(int)
d[0] = 1

s, ans = 0, 0

for a in A:
    s += a
    ans += d[s]
    d[s] += 1

print (ans)