#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> findSubArrays(long long arr[], long long n) {
  map<long long, vector<long long>> map;
  vector<pair<long long, long long>> out;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) out.push_back(make_pair(0, i));
    if (map.find(sum) != map.end()) {
      vector<long long> vc = map[sum];
      for (auto it = vc.begin(); it != vc.end(); it++)
        out.push_back(make_pair(*it + 1, i));
    }
    map[sum].push_back(i);
  }
  return out;
}
int32_t main() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  vector<pair<long long, long long>> out = findSubArrays(arr, n);
  if (out.size() == 0)
    cout << 0 << endl;
  else
    cout << out.size() << endl;
  return 0;
}
