#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  vector<long long int> fac(n + 2);
  fac[0] = 1;
  for (int i = 1; i < n + 2; i++) fac[i] = fac[i - 1] * i;
  for (int i = 0; i < n; i++) cin >> a[i];
  vector<long long int> sum(n + 1);
  sum[0] = 0;
  for (int i = 0; i < n; i++) {
    sum[i + 1] += sum[i] + a[i];
  }
  sort(sum.begin(), sum.end());
  long long int ans = 0;
  long long int tmp = 0;
  for (int i = 0; i < n; i++) {
    tmp = 1;
    while (((sum[i] - sum[i + 1]) == 0) && (i < n)) {
      i++;
      tmp++;
    }
    if (tmp > 1) ans += fac[tmp] / (fac[2] * fac[tmp - 2]);
  }
  cout << ans << endl;
  return 0;
}
