using namespace std;

typedef long long ll;

int main(void){
    ll N;
    cin>>N;
    
    ll A[N];
    vector<ll> B(N+1);
    B[0]=0;
    map<ll,ll> p;
    p[0]=0;
    

    for(int i=0;i<N;i++){
        cin>>A[i];
        B[i+1]=A[i]+B[i];
        p[B[i+1]]=0;
    }
    
    sort(B.begin(),B.end());
    for(int i=0;i<N+1;i++){
        p[B[i]]++;
    }
    
    unique(B.begin(),B.end());
    
    int count=0;    
    for(int i=0;i<p.size();i++){
        if(p[B[i]]>=2)count+=(p[B[i]])*(p[B[i]]-1)/2;
    }
    
    cout<<count<<endl;
}