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