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