##include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  int n; cin>>n;
  vector<ll> sum(n,0),calc(n+1,0);
  cin>>sum[0];
  calc[0]=calc[1]=0;
  for(int i=1;i<n;i++){
    ll a; cin>>a;
    sum[i]=sum[i-1]+a;
    calc[i+1]=calc[i]+i;
  }
  ll ans=0;
  sort(sum.begin(),sum.end());
  if(sum[0]==0) ans++;
  for(int i=0;i<n;i++){
    int c=1,log=i+1;
    while(log<n){
      if(sum[log]==0) ans++;
      if(sum[i]==sum[log]){
        c++; log++;
      }else break;
    }
    ans+=calc[c];
    i=log-1;
  }
  cout<<ans<<endl;
}