#include <bits/stdc++.h>
using namespace std;
int popcount(unsigned int x) {
  x -= x >> 1 & 0x55555555;
  x = (x & 0x33333333) + (x >> 2 & 0x33333333);
  x = x + (x >> 4) & 0x0F0F0F0F;
  return x * 0x01010101 >> 24;
}
int tzcnt(unsigned int x) { return popcount(~x & x - 1); }
struct Point {
  int x, y;
  Point(int p, int q) : x(p), y(q) {}
};
int sum[200000 + 1];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  sum[0] = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> sum[i];
    sum[i] += sum[i - 1];
  }
  long long ans = 0;
  for (int i = 2; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      if (i + j - 1 > N) continue;
      if ((sum[i + j - 1] - sum[j - 1]) == 0) {
        ans++;
      }
    }
  }
  cout << (ans) << "\n";
  int aaa;
  cin >> aaa;
}
