#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
ll gcd(ll a, ll b) {
  if (b > a) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}
ll rep_jijo(ll n, ll x) {
  if (x == 0) return 1;
  if (x % 2 == 0) {
    ll t = rep_jijo(n, x / 2);
    return t * t % 1000000007;
  }
  return n * rep_jijo(n, x - 1) % 1000000007;
}
ll c2(ll n) { return n * (n - 1) / 2; }
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (ll i = 0; i < (ll)(n); i++) cin >> a[i];
  vector<ll> s(n + 1);
  for (ll i = 0; i < n; ++i) s[i + 1] = s[i] + a[i];
  vector<ll> cnt(n + 1);
  for (ll i = 0; i < (ll)(n + 1); i++) cnt[s[i]]++;
  ll total = 0;
  for (ll i = 0; i < (ll)(n + 1); i++) total += c2(cnt[i]);
  cout << total << endl;
  return 0;
}
