#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N = 0;
  cin >> N;
  long long *A, *S;
  A = (long long *)malloc(N * sizeof(long long));
  S = (long long *)malloc((N + 1) * sizeof(long long));
  int flag = 0;
  A[0] = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    S[i + 1] = S[i] + A[i];
  }
  sort(S, S + N + 1);
  long long X = S[0];
  long long cn = 1;
  for (int y = 0; y < N; y++) {
    if (X == S[y + 1]) cn++;
    if (X != S[y + 1] || y == N - 1) {
      flag += cn * (cn - 1) / 2;
      X = S[y + 1];
      cn = 1;
    }
  }
  cout << flag << endl;
  free(A);
  return 0;
}
