#include <bits/stdc++.h>
using namespace std;
int solve(vector<int> a, int range) {
  int res = 0;
  int sum = 0;
  for (int i = 0; i < range; i++) {
    sum += a[i];
  }
  if (sum == 0) res++;
  for (int i = range; i < a.size(); i++) {
    sum += -a[i - range] + a[i];
    if (sum == 0) res++;
  }
  return res;
}
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  int res = 0;
  for (int i = 1; i < N; i++) {
    res += solve(a, i);
  }
  cout << res << endl;
}
