#include <bits/stdc++.h>
int z[200000][2] = {};
int main() {
  int n, i, j, k;
  long a[200000], sum = 0, cnt = 0;
  scanf("%d", &n);
  for (i = 0; i < n; i++) scanf("%ld", &a[i]);
  for (i = 0; i < n; i++) {
    sum = a[i];
    for (j = i + 1; j < n; j++) {
      sum += a[j];
      if (sum == 0) {
        for (k = 0; k < j; k++) {
          if (z[k][0] == i - 1) z[i][1] += z[k][1];
        }
        z[i][1]++;
        z[i][0] = j;
        cnt += z[i][1];
        break;
      }
    }
  }
  printf("%ld\n", cnt);
}
