#include <bits/stdc++.h>
const long M = 200005;
using namespace std;
inline long read() {
  char c = getchar();
  long x = 0, w = 1;
  while (c > '9' || c < '0') {
    if (c == '-') w = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * w;
}
long n;
long long val[M], sum[M];
long tot = 0;
long long c[M][4];
long long Ans = 0, tmin = 10000000000LL, tmax = -10000000000LL;
map<long long, long> p;
bool vis[M];
inline void Calc() {
  for (long i = 0; i <= n; i++) {
    c[i][0] = 1;
    for (long j = 1; j <= i; j++) c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
  }
}
int main() {
  n = read();
  Calc();
  p[0] = 1;
  for (long long i = 1; i <= n; i++) {
    val[i] = read();
    sum[i] = sum[i - 1] + val[i];
    ++p[sum[i]];
    tmin = min(tmin, sum[i]);
    tmax = max(tmax, sum[i]);
  }
  for (long long i = tmin; i <= tmax; i++)
    if (p[i] >= 2) Ans += c[p[i]][2];
  printf("%lld\n", Ans);
  return 0;
}
