#include <bits/stdc++.h>
using namespace std;
long long a[100010], b[100010], ans;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  cin >> a[0];
  b[0] = a[0];
  for (int i = 1; i < n; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + a[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 2; j < n; j++) {
      if (b[j] == b[i]) {
        ans++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (b[i] == 0) {
      ans++;
    }
    cout << ans;
  }
}
