#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<ll> P(N + 1);
  map<ll, int> counter;
  P[0] = 0;
  counter[0]++;
  for (int i = 1; i <= N; i++) {
    P[i] = P[i - 1] + A[i - 1];
    counter[P[i]]++;
  }
  ll res = 0;
  for (auto itr = counter.begin(); itr != counter.end(); itr++)
    res += itr->second * (itr->second - 1) / 2;
  cout << res << '\n';
  return 0;
}
