#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int i, j, k;
  long long int save, count = 0;
  cin >> n;
  long long int a[n + 1];
  a[0] = 0;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  for (i = 2; i <= n; i++) {
    for (j = 0; j <= n - i; j++) {
      save = a[j + i] - a[j];
      if (save == 0) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
