#include <bits/stdc++.h>
int main(int argc, char **argv) {
  int n, i, j, x;
  int xx = 0;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 0; i < n; i++) {
    x = a[i];
    for (j = 1; j < n - i; j++) {
      x = x + a[i + j];
      if (x == 0) xx++;
    }
  }
  printf("%d\n", xx);
  return 0;
}
