#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n;cin>>n;
  map<ll,ll> mp;
  mp[0]++;vector<ll> v={0};
  ll s=0;
  rep(i,n){
    ll a;cin>>a;s+=a;
    mp[s]++;v.push_back(s);
  }
  sort(v,begin(),v.end());
  v.erase(unique(v,begin(),v.end()),v.end());
  ll ans=0;
  rep(i,v.size()){
    ll num=mp[v[i]];
    ans+=num*(num-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}