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