import numpy as np
N = int(input())
A = np.array([0] + list(map(int, input().split())))
B = np.cumsum(A)
B.sort()
cnt = 1
out = 0
for k in range(N):
  if B[k] == B[k+1]:
    cnt += 1
    if k == N-1:
      out += (cnt * (cnt - 1)) // 2
    print('cnt: {}'.format(cnt))
  else:
    out += (cnt * (cnt - 1)) // 2
    cnt = 1
    print('out: {}'.format(out))
print(out)