#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), s(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  s.at(0) = a.at(0);
  for (int i = 1; i <= n - 1; i++) {
    s.at(i) = s.at(i - 1) + a.at(i);
  }
  sort(s.begin(), s.end());
  int i = 0, cnt1 = 0;
  while (i < n) {
    int cnt2 = 1;
    while (i < n - 1 && s.at(i) == s.at(i + 1)) {
      if (s.at(i) == 0) {
        cnt1++;
      }
      i++;
      cnt2++;
    }
    cnt1 += (cnt2 * (cnt2 - 1)) / 2;
    i++;
  }
  cout << (cnt1 == 0 ? 0 : cnt1 + 1) << endl;
  return 0;
}
