#include <bits/stdc++.h>
const int INF = 2147483647;
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n + 1, 0);
  for (long long i = (1); i < (n + 1); i++) {
    ll in;
    cin >> in;
    a[i] = a[i - 1] + in;
  }
  ll res = 0;
  for (ll i = 1; i < n; i++) {
    for (ll j = 0; j <= n - i; j++) {
      if (a[j + i] - a[j] == 0) {
        res++;
      }
    }
  }
  cout << res << endl;
  return 0;
}
