n=int(input())
import numpy as np
a=np.array(input().split(),dtype=int)
a=np.hstack((np.zeros(1,dtype=int),a))
suma=np.cumsum(a)

ans=0
for i in range(1,n):
  diff=suma[i:]-suma[:-i]
  ans+=len(diff)-np.count_nonzero(diff)
  
print(ans)
