#include <bits/stdc++.h>
using namespace std;
int N;
char str[100001];
int main() {
  scanf("%d", &N);
  vector<long long> A(N);
  for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
  for (int i = 1; i < N; i++) A[i] += A[i - 1];
  sort(A.begin(), A.end());
  int count = 0, ans = 0;
  if (A[0] == 0) ans = 0;
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i - 1]) {
      count++;
    } else {
      ans += count * (count + 1) / 2;
      count = 0;
    }
  }
  printf("%d", ans += count * (count + 1) / 2);
  return 0;
}
