#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned int N;
  int tmp = 0, count = 0, sum = 0;
  cin >> N;
  vector<int> A = {};
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    A.push_back(tmp);
  }
  for (int i = 2; i < N; i++) {
    for (int j = 0; j < N - (i - 1); j++) {
      if (accumulate(&A[j], &A[j + i], 0) == 0) count++;
    }
  }
  cout << count << endl;
  system("pause");
  return 0;
}
