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