#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const long long INF = 1LL << 29;
const long long mod = 1e9 + 7;
long long N;
long long A[2 * 100000];
long long kari[2 * 100000];
long long adv[2 * 100000] = {};
long long cnt = 0;
long long dfs(long long i) {
  if (i == N - 1) return 0;
  for (long long(j) = (0); (j) < (N); ++j) {
    if (kari[j] == i) {
      dfs(i + 1);
      return 0;
    }
  }
  adv[i] = A[i];
  if (adv[i] == 0) cnt++;
  for (long long(j) = (1); (j) < (N - i); ++j) {
    adv[i + j] = adv[i + j - 1] + A[i + j];
    if (adv[i + j] == 0) {
      kari[i] = i + j + 1;
      cnt++;
    }
  }
  for (long long(j) = (0); (j) < (N); ++j) adv[j] = 0;
  dfs(i + 1);
  return 0;
}
int main() {
  cin >> N;
  for (long long(i) = (0); (i) < (N); ++i) {
    cin >> A[i];
  }
  for (long long(i) = (0); (i) < (2 * 100000); ++i) kari[i] = -1;
  dfs(0);
  cout << cnt << endl;
  return 0;
}
