#include <bits/stdc++.h>
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];
  }
  int temp;
  for (int i = 0; i < num; i++) {
    for (int j = 0; j < num - i - 1; j++) {
      if (sumArray[j] > sumArray[j + 1]) {
        temp = sumArray[j + 1];
        sumArray[j + 1] = sumArray[j];
        sumArray[j] = temp;
      }
    }
  }
  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);
}
