#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, a[5000];
  cin >> n;
  for (long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long co = 0;
  long long b[5000][5000];
  for (long i = 1; i < n + 1; i++) {
    for (long j = 0; j < n - i + 1; j++) {
      for (long k = j; k < j + i; k++) {
        b[i][j] += a[k];
      }
      if (b[i][j] == 0) {
        co += 1;
      }
    }
  }
  cout << co << endl;
}
