#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int64_t s = 0;
  map<int64_t, int> m;
  m[0] = 1;
  int64_t a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    s += a;
    m[s]++;
  }
  int64_t ans = 0;
  for (auto p : m) {
    auto v = p.second;
    if (v > 1) {
      ans += (v * (v - 1) / 2);
    }
  }
  cout << ans << endl;
  return 0;
}
