#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a, b;
  map<long long int, long long int> mp;
  cin >> a;
  long long int ans[n];
  if (a == 0) {
    ans[0] = 1;
  } else {
    ans[0] = 0;
  }
  mp[a] = 0;
  for (int i = 1; i < n; i++) {
    cin >> b;
    a = a + b;
    std::map<long long int, long long int>::iterator itr = mp.find(a);
    if (itr != mp.end()) {
      ans[i] = ans[(itr->second)] + 1;
    } else if (a == 0) {
      ans[i] = 1;
    } else {
      ans[i] = 0;
    }
    mp[a] = i;
  }
  int nans = 0;
  for (int i = 0; i < n; i++) {
    nans += ans[i];
  }
  cout << nans << endl;
  return (0);
}
