#include <map>
#include <vector>
#include <iostream>

using namespace std;
using ll = int64_t;

struct agc023_a{
  int N;
  vector<ll> A;
  map<ll, ll> M;
  void init(){
    cin >> N;
    A.resize(N);
    for(auto&& x:A)cin >> x;
  }
  
  void solve(){
    init();
    ll ans = 0LL;
    M[0] = 1;
    ll t = 0;
    for(auto&& x:A){
      t += x;
      M[t]++;
    }
    for(auto&& x:M){
      ans += x * (x - 1) / 2;
    }
    cout << ans << endl;
  }
  
};

int main(){
  agc023_a ins;
  ins.solve();
}