#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<long long> a(n + 1);
  long long buf = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> buf;
    a.at(i) = buf + a.at(i - 1);
  }
  sort(a.begin(), a.end());
  int counter = 1;
  long long ans = 0;
  for (int i = 1; i < n + 1; i++) {
    if (a.at(i) != a.at(i - 1)) {
      ans += (counter - 1) * counter / 2;
      counter = 1;
    } else {
      counter++;
    }
  }
  ans += (counter - 1) * counter / 2;
  cout << ans << endl;
  return 0;
}
