#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A;
  vector<long long> S;
  long long ps = 0;
  S.push_back(ps);
  for (int i = 0; i < N; i++) {
    int ipst;
    cin >> ipst;
    A.push_back(ipst);
    ps += ipst;
    S.push_back(ps);
  }
  sort(S.begin(), S.end());
  long long cnt = 0;
  for (int i = 1; i < S.size(); i++) {
    int p = 1;
    while (S[i] == S[i - p]) {
      cnt++;
      p++;
      if (p > i) break;
    }
  }
  cout << (cnt) << endl;
  return 0;
}
