#include <bits/stdc++.h>
int scanN(void);
void readA(int *a, int n);
void intPrintf(int p);
void intPrintN(int *a, int n);
void perSum(int *a, int *sum, int n);
int countSumX(int x, int *a, int n);
int main() {
  if (false) {
    std::printf("******debug mode********\n");
  }
  int i, j;
  int n = scanN();
  int a[n];
  int sum[n];
  readA(a, n);
  perSum(a, sum, n);
  if (false) {
    std::printf("******debug********\n");
    std::printf("a[] = ");
    intPrintN(a, n);
    std::printf("sum[] = ");
    intPrintN(sum, n);
    std::printf("count = \n");
    std::printf("******debug********\n");
  }
  intPrintf(countSumX(0, sum, n));
  return 0;
}
int countSumX(int x, int *a, int n) {
  int i, k;
  static int j;
  static int count;
  int same[n];
  for (i = 0; i < n; i++) {
    if (a[i] == x) count++;
    if (j > 0) {
      for (k = 0; k < j; k++) {
        if (a[i] == same[k]) count++;
      }
    }
    same[j] = a[i];
    j++;
  }
  if (false) {
    std::printf("******debug********\n");
    intPrintN(same, n);
    std::printf("******debug********\n");
  }
  return count;
}
void perSum(int *a, int *sum, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (i == 0)
      sum[i] = a[i];
    else
      sum[i] = a[i] + sum[i - 1];
  }
}
int scanN(void) {
  static int n;
  if (std::scanf("%d", &n)) {
  } else {
    std::printf("scanN error\n");
    std::exit(1);
  }
  return n;
}
void readA(int *a, int n) {
  int ireadA;
  for (ireadA = 0; ireadA < n; ireadA++) {
    if (std::scanf("%d", &a[ireadA])) {
    } else {
      std::printf("readA error\n");
      std::exit(1);
    }
  }
}
void intPrintf(int p) {
  if (std::printf("%d\n", p)) {
  } else {
    std::printf("intPrintf Error\n");
    std::exit(1);
  }
}
void intPrintN(int *a, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (std::printf("%d ", a[i])) {
    } else {
      std::printf("intPrintN Error i = %d stopped \n", i);
      std::exit(1);
    }
  }
  std::printf("\n");
}
