#include <bits/stdc++.h>
using namespace std;
string YN(bool y) { return (y ? "YES" : "NO"); }
string yn(bool y) { return (y ? "Yes" : "No"); }
string ON(bool y) { return (y ? "OK" : "NG"); }
long long Comb(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  r = (n < n - r) ? n : (n - r);
  if (r == 0) return 1;
  if (r == 1) return n;
  vector<int> numerator(r), denominator(r);
  for (int k = 0; k < r; k++) {
    numerator[k] = n - r + k + 1;
    denominator[k] = k + 1;
  }
  for (int p = 2; p <= r; p++) {
    int pivot = denominator[p - 1];
    if (pivot > 1) {
      int offset = (n - r) % p;
      for (int k = p - 1; k < r; k += p) {
        numerator[k - offset] /= pivot;
        denominator[k] /= pivot;
      }
    }
  }
  long long result = 1;
  for (int k = 0; k < r; k++) {
    if (numerator[k] > 1) result *= numerator[k];
  }
  return result;
}
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n), sum(n + 1, 0), count;
  for (int i = (int)(0); i < (int)(n); i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  sort((sum).begin(), (sum).end());
  int cnt = 1;
  for (int i = (int)(0); i < (int)(n); i++) {
    if (sum[i + 1] == sum[i]) {
      cnt++;
    } else {
      count.push_back(cnt);
      cnt = 1;
    }
  }
  count.push_back(cnt);
  long long ans = 0;
  for (int i = (int)(0); i < (int)(count.size()); i++) {
    ans += Comb(count[i], 2);
  }
  cout << ans << endl;
}
