#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
long long a[maxn];
long long f[maxn];
int main() {
  int N;
  scanf("%d", &N);
  long long ans = 0;
  scanf("%lld", &a[0]);
  f[0] = a[0];
  for (int i = 1; i < N; i++) {
    scanf("%lld", &a[i]);
    f[i] = f[i - 1] + a[i];
  }
  sort(f, f + N);
  int pos = 0;
  int l = 0;
  for (int i = 0; i < N; i++) {
    if (f[i] == 0) ans++;
    if (f[i] == f[pos])
      l++;
    else {
      pos = i;
      ans += (long long)(l * (l - 1)) / 2;
      l = 1;
    };
  }
  ans += (long long)(l * (l - 1)) / 2;
  printf("%lld\n", ans);
  return 0;
}
