#include <bits/stdc++.h>
const int maxn = (int)2e5 + 5;
const int inf = 0x3f3f3f3f;
const int MOD = (int)1e9 + 9;
using namespace std;
void quick_sort(long long* array, int lower, int upper) {
  int tmp;
  int mid = (upper + lower) / 2;
  int pivot = array[mid];
  int tlower = lower;
  int tupper = upper;
  while (tlower <= tupper) {
    while (array[tlower] < pivot) {
      tlower++;
    }
    while (array[tupper] > pivot) {
      tupper--;
    };
    if (tlower <= tupper) {
      tmp = array[tlower];
      array[tlower] = array[tupper];
      array[tupper] = tmp;
      tlower++;
      tupper--;
    }
  }
  if (lower < tupper) {
    quick_sort(array, lower, tupper);
  }
  if (tlower < upper) {
    quick_sort(array, tlower, upper);
  }
}
int a[maxn];
long long sum[maxn];
int main() {
  int n;
  scanf("%d", &n);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
    if (sum[i] == 0) ans++;
  }
  quick_sort(sum, 1, n);
  int cnt = 0;
  int c = sum[1];
  sum[n + 1] = inf;
  for (int i = 1; i <= n + 1; i++) {
    if (c == sum[i])
      cnt++;
    else {
      if (cnt >= 2) ans += (cnt * (cnt - 1) / 2);
      c = sum[i];
      cnt = 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
