#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];
  for (int j = 0; j < N; j++) {
    scanf("%d", &matrix[j]);
  }
  for (int i = 0; i < N; i++) {
    int ans = matrix[i];
    for (int j = 1; i + j < N; j++) {
      ans += matrix[i + j];
      if (ans == 0) counter++;
    }
  }
  printf("%d", counter);
  return 0;
}
int main() {
  get_problem();
  return 0;
}
