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