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