#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<long long> S(N + 1);
  for (int i = 0; i < N; i++) S.at(i + 1) = S.at(i) + A.at(i);
  sort(S.begin(), S.end());
  map<long long, int> M;
  for (auto v : S) {
    if (M.count(v))
      M[v]++;
    else
      M[v] = 1;
  }
  long long ans = 0;
  for (auto p : M) ans += p.second * (p.second - 1) / 2;
  cout << ans << endl;
}
