#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), s(n + 1, 0);
  map<int, int> seq;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
    seq[s[i + 1]]++;
  }
  seq[0]++;
  auto combination = [&](int x) { return x * (x - 1) / 2; };
  ll ans = 0;
  for (int i = 1; i < n + 1; i++) {
    if (seq[s[i]] > 1) {
      ans += combination(seq[s[i]]);
      seq[s[i]] = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
