#include <bits/stdc++.h>
using namespace std;
long long fac[200001], finv[200001], inv[200001];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < 200001; i++) {
    fac[i] = fac[i - 1] * i % 1000000007;
    inv[i] = 1000000007 - inv[1000000007 % i] * (1000000007 / i) % 1000000007;
    finv[i] = finv[i - 1] * inv[i] % 1000000007;
  }
}
unsigned long long comb(unsigned long long n, unsigned long long r,
                        long long finv[]) {
  unsigned long long ncr = 1;
  for (int i = 1; i <= r; i++) {
    ncr *= n - i + 1;
    ncr %= 1000000007;
  }
  ncr *= finv[r];
  ncr %= 1000000007;
  return ncr;
}
int main() {
  COMinit();
  int n;
  cin >> n;
  vector<long long> v(n + 1);
  v[0] = 0;
  for (int i = 0; i < (n); i++) {
    long long t;
    cin >> t;
    v[i + 1] = v[i] + t;
  }
  sort(v.begin(), v.end());
  int ans = 0;
  vector<int> r(10, 0);
  for (int i = 0; i < (n + 1); i++) {
    r[v[i]]++;
  }
  for (int i = 0; i < 10; i++) {
    if (r[i] > 1) {
      ans += comb(r[i], 2, finv);
    }
  }
  cout << ans;
}
