#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) os << exchange(dlm, " ") << x;
  return os;
}
template<typename T>
T ncr(T n, T r){
  T ret=1;
  for(size_t i=n-r+1; i<=n; ++i) ret*=i;
  for(size_t i=1; i<=r; ++i) ret/=i;
  return ret;
}
int32_t main(){
  size_t n; cin>>n;
  vector<int32_t> a(n),s(n+1); for(auto&& x:a) cin>>x;
  s[0]=0; for(size_t i=1; i<n+1; ++i) s[i]=s[i-1]+a[i-1];
  // cout<<s<<endl;
  std::map<int32_t,size_t> m;
  for(const auto& x:s) ++m[x];
  // for(const auto& [k,v]:m) cout<<k<<' '<<v<<'\n';

  size_t ret=0;
  for(const auto& x:m){
    if(x.second>1) ret+=ncr<size_t>(x.second, 2);
  }
  cout<<ret<<endl;
}