#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
template<typename T> 
using gmap = cc_hash_table<T, T, hash<T> >;

//INSERT ABOVE HERE
signed AGC023_A(){
  using ll = long long;
  int n;
  cin>>n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) cin>>a[i];

  ll ans=0;
  map<ll, ll> m;
  int s=0;
  m[s]++;
  for(int i=0;i<n;i++){
    s+=a[i];
    ans+=m[s];
    m[s]++;
  }
  
  cout<<ans<<endl;
  return 0;
}

signed main(){
  AGC023_A();
  return 0;
}
