#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num = 0;
  cin >> n;
  int a[n + 1], h[n + 1];
  memset(h, 0, sizeof(h));
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    h[i] += h[i - 1] + a[i];
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 2; j <= n; j++) {
      num += ((h[j] - h[i]) == 0 ? 1 : 0);
    }
  }
  cout << num;
  return 0;
}
