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