#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> S(n + 1);
  S[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
  }
  sort(S.begin(), S.end());
  long long count = 0;
  for (int i = 0; i < n; i++) {
    if (S[i] == S[i + 1]) {
      for (int j = i + 1; j <= n; j++) {
        if (S[i] == S[j]) {
          count++;
        } else {
          break;
        }
      }
    }
  }
  cout << count;
  return 0;
}
