#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long A[200010], sum[200010];
  map<int, int> counts;
  int i;
  scanf("%d", &N);
  sum[0] = 0;
  for (i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for (i = 1; i < N + 1; i++) {
    sum[i] = sum[i - 1] + A[i - 1];
  }
  for (i = 0; i < N + 1; i++) {
    if (counts.find(sum[i]) != counts.end()) {
      counts[sum[i]] += 1;
    } else {
      counts[sum[i]] = 1;
    }
  }
  long long ans = 0;
  for (auto x : counts) {
    long long n = x.second;
    ans += n * (n - 1) / 2;
  }
  printf("%lld", ans);
  return 0;
}
