#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "\t";
  }
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
int N;
vector<int> A;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  for (long long i = 0; i < (N); i++) {
    int t;
    cin >> t;
    A.push_back(t);
  }
  vector<int> Asum(N + 1);
  int sum = 0;
  for (long long i = 0; i < (N); i++) {
    sum += A[i];
    Asum[i + 1] = sum;
  }
  int ans = 0;
  for (int i = 1; i < N; i++) {
    for (int j = i; j <= N; j++) {
      int s = Asum[j] - Asum[j - i];
      if (s == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
