#include <bits/stdc++.h>
void Sort(int array[], int left, int right) {
  if (left < right) {
    int pivot = array[left];
    int i = left, j = right, temp;
    while (1) {
      while (pivot < array[j]) j--;
      if (i >= j) break;
      temp = array[j];
      array[j] = array[i];
      array[i] = temp;
      i++;
    }
    Sort(array, left, i - 1);
    Sort(array, j + 1, right);
  }
}
int main() {
  int num;
  int *sumArray;
  scanf("%d", &num);
  sumArray = (int *)malloc((num + 1) * sizeof(int));
  sumArray[0] = 0;
  for (int i = 1; i <= num; i++) {
    scanf("%d", &sumArray[i]);
    sumArray[i] += sumArray[i - 1];
  }
  Sort(sumArray, 0, num);
  int cnt = 1;
  int combi = 0;
  for (int i = 0; i < num; i++) {
    if (sumArray[i] == sumArray[i + 1]) {
      cnt++;
    } else {
      combi += (cnt * (cnt - 1)) / 2;
      cnt = 1;
    }
  }
  combi += (cnt * (cnt - 1)) / 2;
  printf("%d", combi);
  free(sumArray);
}
