#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
	int ans=0,n,f;
	cin>>n;
  	long long a[n],s[n+1]={0},tmp,tc=1;
  	for(int i=0;i<n;i++){
    	cin>>a[i];
      	s[i+1]=s[i]+a[i];
    }
  	sort(s,s+n+1);
  tmp=s[0];
  	for(int i=1;i<=n;i++){
      //cout<<s[i]<<endl;
      	if(s[i]==tmp){
          	tc++;
          f=1;
        }else{
          tmp=s[i];
          //cout<<(tc*(tc-1))/2;
          ans+=(tc*(tc-1))/2;
          tc=1;
          f=0;
        }
    }
  	if(f)ans+=(tc*(tc-1))/2;
	cout << ans << endl;
}
