#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  vector<long long> ps_a(n);
  partial_sum(a.begin(), a.end(), ps_a.begin());
  int answer = 0;
  for (int i = 1; i < n; i++)
    if (ps_a.at(i) == 0) answer++;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (ps_a.at(j) - ps_a.at(i) == 0) answer++;
    }
  }
  cout << answer << endl;
}
