#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int cnt = 0;
  int temp = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    temp += a[i];
    if (!temp || !a[i]) cnt++;
    if (i && a[i] + a[i - 1] == 0) cnt++;
  }
  for (int i = 1; i < n - 1; ++i) {
    temp = a[i] + a[i + 1];
    for (int j = i + 2; j < n; j++) {
      temp += a[j];
      if (!temp) ++cnt;
    }
  }
  printf("%d\n", cnt);
  return 0;
}
