#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main (){
    map<ll,ll>mp;
    int t;cin>>t;
    ll tmp=0,ans=0;
    while(t--){
        ll n;cin>>n;
        tmp+=n;
        if(tmp==0) ans+=(mp[0]++)+1;
        else ans+=mp[tmp]++;
    }
    cout<<ans<<endl;
    return 0;
}
