#include <bits/stdc++.h>
static const long long int MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const long long int MOD = 1e9 + 7;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
long long int modpow(long long int a, long long int n) {
  long long int ret = 1;
  while (n > 0) {
    if (n & 1) ret = ret * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return ret;
}
long long int modinv(long long int a) { return modpow(a, MOD - 2); }
long long int comb(long long int n, long long int r) {
  long long int ret = 1;
  for (long long int i = 0; i < r; i++) ret = ret * (n - i) % MOD;
  for (long long int i = 1; i <= r; i++) ret = ret * modinv(i) % MOD;
  return ret;
}
int main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> sum(n + 1, 0);
  long long int ans = 0, count = 0, mem = 0;
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  sum[0] = 0;
  for (int i = 0; i < (int)(n); i++) sum[i + 1] = sum[i] + a[i];
  sort(sum.begin(), sum.end());
  mem = -1;
  for (int i = 0; i < (int)(n + 1); i++) {
    if (mem == sum[i]) {
      count++;
    } else {
      if (count >= 2) ans += comb(count, 2);
      count = 1;
      mem = sum[i];
    }
  }
  if (count >= 2) ans += comb(count, 2);
  cout << ans;
}
