#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  vector<ll> vec(N);
  for (ll i = 0; i < N; i++) cin >> vec[i];
  if (N == 1) {
    if (vec[0] == 0)
      cout << 1 << "\n";
    else
      cout << 0 << "\n";
  } else if (N == 2) {
    ll res = 0;
    if (vec[0] == 0) res++;
    if (vec[1] == 0) res++;
    if (vec[0] + vec[1] == 0) res++;
    cout << res << "\n";
  } else {
    vector<ll> partial = {0};
    copy(vec.begin(), vec.end(), back_inserter(partial));
    partial_sum(partial.begin(), partial.end(), partial.begin());
    ll res = 0;
    for (ll i = 0; i < N; ++i) {
      if (vec[i] == 0) res++;
    }
    ll left, right, interval_sum;
    for (ll i = N; i >= 2; --i) {
      for (ll j = 1; j <= N - i + 1; ++j) {
        left = j - 1, right = j + i - 1;
        interval_sum = partial[right] - partial[left];
        if (interval_sum == 0) res++;
      }
    }
    cout << res << "\n";
  }
  return 0;
}
