#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200010];
  long long ans = 0;
  long long tmp;
  int plus;
  long long memo[200010];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  memo[0] = a[0];
  for (int i = 1; i < n; i++) {
    memo[i] = memo[i - 1] + a[i];
  }
  for (int i = 1; i < n; i++) {
    for (int j = i; j < n; j++) {
      if (j == i) {
        tmp = memo[j];
      } else {
        tmp = memo[j] - memo[j - (i + 1)];
      }
      if (tmp == 0) {
        ans++;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
