#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
int64_t fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  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;
  }
}
int64_t COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  COMinit();
  int64_t N;
  cin >> N;
  vector<int64_t> A(N), B(N + 1, 0);
  for (int64_t i = 0; i < N; i++) {
    cin >> A[i];
    B[i + 1] += A[i] + B[i];
  }
  map<int64_t, int64_t> cnt;
  for (auto e : B) {
    cnt[e]++;
  }
  int64_t ans = 0;
  for (auto i = cnt.begin(); i != cnt.end(); i++) {
    ans += COM(i->second, 2);
  }
  cout << ans << "\n";
}
