from collections import defaultdict N=int(input()) A=list(map(int,input().split())) C=[0]+A for i in range(1,N+1): C[i]+=C[i-1] dct=defaultdict(list) for i in range(N): dct[(A[i],C[i]-i*A[i])].append(i) ans=N*(N-1)//2 for lst in dct.values(): le=len(lst) ans-=le*(le-1)//2 ans+=1 print(ans)