import sys
from collections import Counter
import random
import numpy as np
import time

n=int(input())
a=list(map(int,input().split()))
S=[0]
for i in range(n):
    S.append(S[i]+a[i])
#for i in S:print(i)
m=n+1
c=0
for i in range(1,m):
    c+=S[:i].count(S[i])
print(c)