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