#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int a[1000000];
  int sa[1000000];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int c = 0;
  sa[0] = 0;
  for (int i = 0; i < n; i++) {
    sa[i + 1] = a[i] + sa[i];
    if (sa[i + 1] == 0) c++;
  }
  int ans;
  if (n % 2 == 0)
    ans = c * n / 2;
  else
    ans = c * (n / 2 + 1);
  cout << ans << endl;
}
