#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = ((long long)0); i < ((long long)N); i++) cin >> A[i];
  for (long long i = ((long long)0); i < ((long long)N - 1); i++)
    A[i + 1] += A[i];
  sort(A.begin(), A.end());
  long long ans = 0;
  for (long long i = ((long long)0); i < ((long long)N); i++)
    if (A[i] == 0) ans++;
  for (long long i = ((long long)0); i < ((long long)N); i++) {
    long long j = i;
    while (A[i] == A[j]) j++;
    ans += (j - i) * (j - i - 1) / 2;
    i = j - 1;
  }
  cout << ans << endl;
}
