#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p;
  cin >> n;
  long long cnt = 0;
  vector<vector<long long> > sum;
  sum.resize(n);
  for (int i = 0; i < n; i++) {
    sum[i].resize(i + 1);
  }
  for (int i = 0; i < n; i++) {
    cin >> sum[i][0];
    for (int j = 1; j <= i; j++) {
      sum[i][j] = sum[i - 1][j - 1] + sum[i][0];
      if (sum[i][j] == 0) cnt++;
      assert(false);
    }
  }
  cout << cnt << endl;
  return 0;
}
