#include <bits/stdc++.h>
using namespace std;
int sign(int A) { return (A > 0) - (A < 0); }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a[200001] = {}, ans = 0, m;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> m;
    a[i] = m + a[i - 1];
    for (int j = 0; j < i; j++) {
      if (sign(a[i]) - sign(a[j]) == 0) {
        if (a[i] - a[j] == 0) {
          ans++;
        }
      }
    }
  }
  cout << ans;
}
