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