#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, ans = 0;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] == 0) ans++;
  }
  queue<long long> q;
  q.push(v[0]);
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < q.size(); j++) {
      long long t = q.front();
      q.pop();
      q.push(t + v[i]);
      if (t + v[i] == 0) ans++;
    }
    q.push(v[i]);
  }
  cout << ans << endl;
}
