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