#include <bits/stdc++.h>
void q_sort(int numbers[], int left, int right) {
  int pivot, l_hold, r_hold;
  l_hold = left;
  r_hold = right;
  pivot = numbers[left];
  while (left < right) {
    while ((numbers[right] >= pivot) && (left < right)) right--;
    if (left != right) {
      numbers[left] = numbers[right];
      left++;
    }
    while ((numbers[left] <= pivot) && (left < right)) left++;
    if (left != right) {
      numbers[right] = numbers[left];
      right--;
    }
  }
  numbers[left] = pivot;
  pivot = left;
  left = l_hold;
  right = r_hold;
  if (left < pivot) q_sort(numbers, left, pivot - 1);
  if (right > pivot) q_sort(numbers, pivot + 1, right);
}
int main(void) {
  int n;
  int a;
  int b[200001] = {0};
  int out = 0;
  int sum = 0;
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a);
    sum += a;
    b[i + 1] = sum;
  }
  q_sort(b, 0, n);
  for (i = 1; i < n + 1; i++) {
    static int count = 0;
    if (b[i - 1] == b[i])
      out += ++count;
    else
      count = 0;
  }
  printf("%d\n", out);
  return 0;
}
