#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int last = 0;
  map<int, int> pre;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    last += x;
    ++pre[last];
  }
  int ans = 0;
  for (auto &kv : pre) {
    if (kv.first == 0)
      ans += kv.second * (kv.second + 1) / 2;
    else
      ans += (kv.second - 1) * (kv.second) / 2;
  }
  cout << ans << endl;
  return 0;
}
