#include <bits/stdc++.h>
using namespace std;
long long int findSubArrays(vector<long long int> arr, int n) {
  unordered_map<long long int, vector<int>> map;
  vector<pair<int, int>> out;
  long long int sum = 0;
  for (int 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<int> 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 ((int)out.size());
}
void solve(int testcase) {
  int n;
  cin >> n;
  vector<long long int> v(n);
  for (int i = (0); i <= (n - 1); i++) cin >> v[i];
  cout << findSubArrays(v, n);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(2);
  clock_t b = clock();
  int t = 1;
  for (int tt = (1); tt <= (t); tt++) solve(tt);
  clock_t e = clock();
  cerr << (double(e - b) / CLOCKS_PER_SEC) << " sec";
  return 0;
}
