#include <bits/stdc++.h>
using namespace std;
long long int MOD = 1000000007;
long long int INFL = 1ll << 60;
long long int INF = 1 << 30;
const long long MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void nCr_init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}
int main() {
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  map<long long int, long long int> rui;
  long long int s = 0;
  for (int i = 0; i < n; i++) {
    s += v[i];
    rui[s]++;
  }
  rui[0]++;
  nCr_init();
  long long int ans = 0;
  for (auto x : rui) {
    ans += nCr(x.second, 2);
  }
  cout << ans << endl;
}
