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