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