#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> S(N);
  S[0] = A[0];
  for (int i = 1; i < N; i++) S[i] = S[i - 1] + A[i];
  map<long long, long long> kazu;
  for (int i = 0; i < N; i++) kazu[S[i]]++;
  long long ans = 0;
  for (auto x : kazu) {
    long long t = x.second;
    ans += t * (t - 1) / 2;
  }
  cout << ans << endl;
}
