#include <bits/stdc++.h>
using namespace std;
map<long long, int> p, q;
const int N = 2e5 + 5;
int n;
long long sum[N], ans, c[N][3];
inline int read() {
  int x = 0, w = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + c - '0';
    c = getchar();
  }
  return x * w;
}
int main() {
  n = read();
  for (register int i = 0; i <= n; i++) {
    c[i][0] = 1;
    if (i == 0) continue;
    for (register int j = 1; j <= min(i, 2); j++)
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
  }
  p[0] = 1;
  for (register int i = 1; i <= n; i++) {
    int x = read();
    sum[i] = sum[i - 1] + x;
    ++p[sum[i]];
  }
  for (register int i = 1; i <= n; i++) {
    if (q[sum[i]]) continue;
    if (p[sum[i]] > 1) ans += c[p[sum[i]]][2];
    q[sum[i]] = 1;
  }
  printf("%lld\n", ans);
  return 0;
}
