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