#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A[300000], S[300000], ans = 0;
  cin >> N;
  S[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 rensa = 1;
  for (int i = 0; i <= N; i++) {
    if (S[i] == S[i + 1]) {
      ans += rensa++;
      ;
    } else
      rensa = 1;
  }
  cout << ans << endl;
}
