#include <bits/stdc++.h>
using namespace std;
int a[200010];
long long s[200010];
int main() {
  int n;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
  sort(s, s + n + 1);
  for (int i = 0, j; i <= n; i = j) {
    for (j = i; s[i] == s[j]; j++)
      ;
    ans += 1ll * (j - i) * (j - i - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
