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