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