#include <bits/stdc++.h>
int mamegu(const void* x, const void* y) {
  int a = *(const int*)x, b = *(const int*)y;
  return a < b ? -1 : a > b;
}
int N;
int A[222222];
int zc;
int64_t z[222222];
int64_t nakamayukie[222222];
int yukati[222222];
int zq(int satorina) {
  int l = 0, r = zc - 1;
  while (l <= r) {
    int m = l + (r - l) / 2;
    if (z[m] == satorina)
      return m;
    else if (z[m] < satorina)
      l = m + 1;
    else
      r = m - 1;
  }
  printf("ERROR: %d not found\n", satorina);
  exit(2);
}
int main(void) {
  int i;
  int64_t kiyononn = 0;
  if (scanf("%d", &N) != 1) return 1;
  for (i = 1; i <= N; i++) {
    if (scanf("%d", &A[i]) != 1) return 1;
  }
  for (i = 1; i <= N; i++) {
    z[i] = nakamayukie[i] = nakamayukie[i - 1] + A[i];
  }
  qsort(z, N + 1, sizeof(*z), mamegu);
  zc = 1;
  for (i = 1; i <= N; i++) {
    if (z[zc - 1] != z[i]) z[zc++] = z[i];
  }
  for (i = 0; i <= N; i++) {
    yukati[zq(nakamayukie[i])]++;
  }
  for (i = 0; i < zc; i++) {
    if (yukati[i] > 1) kiyononn += (int64_t)yukati[i] * (yukati[i] - 1) / 2;
  }
  printf("%" PRId64 "\n", kiyononn);
  return 0;
}
