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