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