#include <bits/stdc++.h>
using namespace std;
int main(void) {
  std::ios::sync_with_stdio(false);
  int n;
  long long a[200003];
  while (cin >> n && n != 0) {
    int i;
    for (i = 0; i < n; ++i) {
      cin >> a[i];
    }
    int sum = 0;
    for (i = 0; i < n; ++i) {
      if (a[i] == 0) sum++;
      long long q = a[i];
      for (int j = i - 1; j >= 0; --j) {
        q += a[j];
        if (q == 0) sum++;
      }
    }
    cout << sum << endl;
  }
  return 0;
}
