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