#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long A[N + 1];
  for (int i = 1; i <= N; ++i) cin >> A[i];
  A[0] = 0;
  long long B[N + 1];
  long long sum = 0;
  for (int i = 0; i <= N; ++i) {
    sum += A[i];
    B[i] = sum;
  }
  sort(B, B + N + 1);
  int counter = 0;
  for (int i = 0; i < N; ++i) {
    int add = 0;
    if (B[i] == B[i + 1]) {
      ++add;
      counter += add;
    } else {
      add = 0;
    }
  }
  cout << counter << endl;
}
