#include <bits/stdc++.h>
using namespace std;
int n;
long long arr[202020], ans;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%lld", &arr[i]);
  for (int k = 1; k <= n; k++) {
    long long hap = 0;
    for (int i = 1; i < k; i++) hap += arr[i];
    for (int i = k; i <= n; i++) {
      hap = hap + arr[i] - arr[i - k];
      if (!hap) ans++;
    }
  }
  printf("%lld", ans);
}
