#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& an : a) {
    cin >> an;
  }
  int out = 0;
  vector<int> table(n, 0);
  for (int i = 0; i < n; i++) {
    table[i] = a[i];
    for (int j = i - 1; j >= 0; j--) {
      table[j] = table[j + 1] + a[j];
      if (table[j] == 0) {
        out++;
      }
    }
  }
  cout << out << endl;
  return 0;
}
