#include <bits/stdc++.h>
using namespace std;
int N;
long long A[200000];
long long cnt[200000];
int main() {
  scanf("%d", &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, A + N);
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    long long tmp = A[i];
    int j = i;
    while (A[j] == tmp) j++;
    int cnt = j - i;
    if (A[i] == 0) cnt++;
    ans += cnt * (cnt - 1) / 2;
    i = j - 1;
  }
  cout << ans << endl;
  return 0;
}
