#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  while (cin >> n && n > 0) {
    vector<int> A(n, 0);
    int sum = 0, counter = 0;
    for (i = 0; i < n; i++) {
      cin >> A[i];
    }
    for (i = 0; i < n; i++) {
      sum = 0;
      for (int j = i; j >= 0; j--) {
        sum += A[j];
        if (sum == 0) {
          counter++;
        }
      }
    }
    cout << counter << endl;
  }
}
