#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

//modしながら塁乗
ll modpow(ll n,ll k){
  if(k == 1){
    return n;
  }else if(k == 0){
    return 1;
  }else if(k%2==0){
    ll memo = modpow(n,k/2)%MOD;
    return memo*memo%MOD;
  }else{
    return n * modpow(n,k-1)%MOD;
  }
}

ll main(){

  ll n;cin>>n;
  ll a[n];
  cin>>a[0];
  for(ll i=1;i<n;i++){
    ll t;cin>>t;
    a[i] = a[i-1] + t;
  }
  vector<ll> v;
  REP(i,n){
    v.pb(a[i]);
  }
  v.pb(0);
  VSORT(v);
  ll ans = 0;
  ll i = 1;
  ll count = 1;
  while(i<v.size()){

    if(v[i] != v[i-1]){
      ans += count * (count - 1) / 2;
      count = 0;
    }
        count++;
    i++;
  }
  ans += count * (count - 1) / 2;

  cout<<ans<<endl;


  return 0;
}