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