#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (!v.empty()) {
    out << '[';
    copy(v.begin(), v.end(), ostream_iterator<T>(out, ", "));
    out << "\b\b]";
  }
  return out;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(16);
  int n;
  cin >> n;
  long long arr[n];
  for (int i = 0; i < (n); i++) cin >> arr[i];
  int ans = 0;
  for (int i = 0; i < n; i++) {
    long long t = arr[i];
    for (int j = i + 1; j < n; j++) {
      t += arr[j];
      if (t == 0) {
        ans++;
      }
    }
    t = arr[i];
    for (int j = i - 1; j > n; j--) {
      t += arr[j];
      if (t == 0) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
