#include <bits/stdc++.h>
using namespace std;
int N;
int solve_problem(int);
int counter = 0;
int get_problem() {
  scanf("%d", &N);
  solve_problem(N);
}
int solve_problem(int N) {
  int matrix[N];
  int m[N - 2][N];
  for (int i = 0; i < N - 1; i++) {
    for (int j = 0; j < N; j++) {
      m[i][j] = 0;
    }
  }
  for (int j = 0; j < N; j++) {
    scanf("%d", &matrix[j]);
  }
  int ans;
  for (int i = 0; i < N - 1; i++) {
    m[0][i] = matrix[i] + matrix[i + 1];
    if (m[0][i] == 0) counter++;
  }
  for (int i = 1; i < N - 1; i++) {
    for (int j = 0; j + i < N - 1; j++) {
      ans = m[i - 1][j + 1] + matrix[j];
      m[i][j] = ans;
      if (ans == 0) counter++;
    }
  }
  printf("%d", counter);
  return 0;
}
int main() {
  get_problem();
  return 0;
}
