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