#include <bits/stdc++.h>
using namespace std;
vector<int> v;
vector<int> s;
int main() {
  int n;
  cin >> n;
  v.resize(n);
  s.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  long long int sum = 0;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    sum += v[i];
    s[i] = sum;
    if (sum == 0) ++ans;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      s[j] -= v[i];
      if (s[j] == 0) ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}
