#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;
ll f[201010], rf[201010];
ll inv(ll x) {
  ll res = 1;
  ll k = MOD - 2;
  ll y = x;
  while (k) {
    if (k & 1) res = (res * y) % MOD;
    y = (y * y) % MOD;
    k /= 2;
  }
  return res;
}
void init() {
  f[0] = 1;
  for (int i = 1; i < 201010; i++) f[i] = (f[i - 1] * i) % MOD;
  for (int i = 0; i < 201010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
  if (n < k) return 0;
  ll a = f[n];
  ll b = rf[n - k];
  ll c = rf[k];
  ll bc = (b * c) % MOD;
  return (a * bc) % MOD;
}
int main() {
  init();
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<ll> sum(n + 1);
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  multiset<ll> ms;
  for (int i = 0; i <= n; i++) {
    ms.insert(sum[i]);
  }
  ll ans = 0;
  for (ll cand : ms) {
    int count = ms.count(cand);
    ans += C(count, 2);
    ms.erase(cand);
  }
  cout << ans << endl;
}
