#include <bits/stdc++.h>
using namespace std;
int scanN(void);
void readA(long long *a, int n);
void intPrintf(int p);
void llPrintN(long long *a, int n);
void perSum(long long *a, long long *sum, int n);
int countSumX(std::map<long long, long long> m, long long *sum, int n);
int N;
long long A[200010];
long long SUM[200010];
std::map<long long, long long> M;
int main() {
  if (false) {
    std::printf("******debug mode********\n");
  }
  int i, j;
  N = scanN();
  readA(A, N);
  perSum(A, SUM, N);
  M[0] = 1;
  if (false) {
    std::printf("******debug********\n");
    std::printf("a[] = ");
    llPrintN(A, N);
    std::printf("sum[] = ");
    llPrintN(SUM, N);
    std::printf("count = \n");
    std::printf("******debug********\n");
  }
  intPrintf(countSumX(M, SUM, N));
  return 0;
}
int countSumX(std::map<long long, long long> m, long long *sum, int n) {
  static int count;
  for (int i = 0; i < N; i++) {
    if (m.find(sum[i]) == m.end()) {
      m[sum[i]] = 1;
    } else {
      m[sum[i]]++;
    }
  }
  for (auto x : m) {
    long long c = x.second;
    count += c * (c - 1) / 2;
  }
  return count;
}
void perSum(long long *a, long long *sum, int n) {
  int i;
  sum[0] = a[0];
  for (i = 1; i < n; i++) {
    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(long long *a, int n) {
  int ireadA;
  for (ireadA = 0; ireadA < n; ireadA++) {
    if (std::scanf("%lld", &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 llPrintN(long long *a, int n) {
  int i;
  for (i = 0; i < n; i++) {
    if (std::printf("%lld ", a[i])) {
    } else {
      std::printf("intPrintN Error i = %d stopped \n", i);
      std::exit(1);
    }
  }
  std::printf("\n");
}
