#include <bits/stdc++.h>
inline long long read() {
  long long tmp = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || '9' < c; c = getchar())
    if (c == '-') f = -1;
  for (; '0' <= c && c <= '9'; c = getchar()) tmp = tmp * 10 + c - '0';
  return tmp * f;
}
inline long long power(long long a, long long b) {
  long long tmp = 1;
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a % 1000000007;
    a = a * a % 1000000007;
  }
  return tmp;
}
using namespace std;
long long a[100010], sum[100010];
int n;
int main() {
  int i;
  n = read();
  for (i = 1; i <= n; i++) a[i] = read(), sum[i] = sum[i - 1] + a[i];
  sort(sum, sum + n + 1);
  sum[n + 1] = -1;
  long long ans = 0, cnt = 0;
  for (i = 0; i <= n; i++) {
    ++cnt;
    if (sum[i] != sum[i + 1]) ans += cnt * (cnt - 1) / 2, cnt = 0;
  }
  printf("%lld\n", ans);
  return 0;
}
