#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[i];
  }
  long long ans = 0;
  long long sum = 0;
  for (long long i = 0; i < n - 1; i++) {
    sum = a[i];
    for (long long j = i + 1; j < n; j++) {
      sum += a[j];
      if (sum == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
