#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long A[200000], sum[200001] = {0}, ans = 0;
  scanf("%d", &N);
  for (int i = (0); i < (N); ++i) {
    scanf(" %lld", &A[i]);
    sum[i + 1] = sum[i] + A[i];
  }
  sort(sum, sum + N + 1);
  int k = 1, j = 0, l = 0, s[200001];
  while (j < N) {
    if (sum[j] == sum[j + 1]) {
      k++;
    } else {
      s[l] = k;
      k = 1;
      l++;
    }
    j++;
  }
  for (int i = (0); i < (l); ++i) {
    ans += l * (l - 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}
