#include<cstdio>
#include<map>
using namespace std;

typedef long long LL;

int N;
LL Ans;

map<LL,int> Cnt;

int main(){
	int i,x;
	LL s=0;
	scanf("%d",&N);
	Cnt[0]++;
	while(N--){
		scanf("%d",&x),s+=x;
		Ans+=Cnt[s];
		Cnt[s]++;
	}
	printf("%lld\n",Ans);
	return 0;
}