#include <bits/stdc++.h>
std::vector<int> v;
std::vector<int> s;
int main() {
  int n;
  std::cin >> n;
  v.resize(n);
  s.resize(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> v[i];
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (j + i >= n) break;
      s[j] += v[j + i];
      if (s[j] == 0) ++sum;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}
