#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, s = 0, tmp = 0;
  cin >> n;
  vector<int64_t> a(n);
  for (int i = 0; i < n; ++i) {
    if (i == 0)
      cin >> a[i];
    else {
      int b;
      cin >> b;
      a[i] = a[i - 1] + b;
    }
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] == a[i + 1]) {
      ++tmp;
      s += tmp;
    } else
      tmp = 0;
  }
  cout << s << endl;
  return 0;
}
