#include <bits/stdc++.h>
using namespace std;
long long ans;
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
signed main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long cnt = 0;
  for (long long i = 1; i < n + 1; i++) {
    cnt = 0;
    for (long long j = 0; j < n - i + 1; j++) {
      if (j == 0) {
        for (long long k = 0; k < i; k++) {
          cnt += a[k];
        }
      } else {
        cnt -= a[j - 1];
        cnt += a[j + i - 1];
      }
      if (cnt == 0) ans++;
    }
  }
  cout << ans << endl;
}
