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