#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int count = 0;
  int plus;
  int minus;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      count++;
    } else if (A[i] > 0) {
      plus = i;
    } else if (A[i] < 0) {
      minus = i;
    }
  }
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum = A[i];
    for (int j = i + 1; j < N; j++) {
      sum += A[j];
      if (sum == 0) {
        count++;
      }
      if ((sum > 0 && j > minus) || (sum < 0 && j > plus)) {
        break;
      }
    }
  }
  cout << count << endl;
  return 0;
}
