#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T>
using vc = vector<T>;
template <class T>
using vvc = vector<vector<T>>;
using vl = vector<ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const long double EPS = 1e-11;
void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
int main() {
  init();
  ll N;
  cin >> N;
  vl A(N);
  for (int i = 0; i < (N); i++) cin >> A[i];
  vl acc(N + 1, 0);
  for (int i = 0; i < (N); i++) acc[i + 1] = acc[i] + A[i];
  sort((acc).begin(), (acc).end());
  ll t = 0, ans = 0;
  ll cnt = 1;
  for (int i = (1); i < (N + 1); i++) {
    if (t == acc[i])
      cnt++;
    else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
      t = acc[i];
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}
