#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using dbl = double;
using pii = pair<int, int>;
using pl4 = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vpii = vector<pii>;
using vvpii = vector<vpii>;
using vpl4 = vector<pl4>;
using vvpl4 = vector<vpl4>;
using vd = vector<dbl>;
using vvd = vector<vd>;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 20;
const ll INF = 1LL << 60;
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll inverse[N];
void init_inverse() {
  inverse[1] = 1;
  for (ll i = 2; i < N; i++)
    inverse[i] = (MOD - MOD / i) * inverse[MOD % i] % MOD;
}
pl4 Bezout(ll a, ll b) {
  if (b != 0) {
    pl4 xy;
    xy = Bezout(b, a % b);
    return make_pair(xy.second, xy.first - ((a / b) * xy.second));
  }
  if (b == 0) {
    return make_pair(1, 0);
  }
}
pl4 Bez(ll a, ll b, ll c) {
  pl4 xy;
  ll x, y, z, gc;
  xy = Bezout(a, b);
  gc = gcd(a, b);
  if (c % gc != 0) return make_pair(-1, -1);
  x = xy.first * (c / gc);
  y = xy.second * (c / gc);
  if (x < 0)
    z = ((((-x) % ((b / gc))) == 0) ? ((-x) / ((b / gc)))
                                    : (((-x) / ((b / gc))) + 1));
  if (x >= 0) z = -x / (b / gc);
  x += z * (b / gc);
  y -= z * (a / gc);
  return make_pair(x, y);
}
void salv(vll v) {
  cout << ("{");
  ;
  for (ll i = (0); i <= (v.size() - 1); i++) {
    cout << (v[i]);
    ;
    if (i != v.size() - 1) cout << (",");
    ;
  }
  cout << ("}") << endl;
}
ll DigS10(ll n) {
  ll m = 0;
  for (ll i = (0);
       i <= (((llabs(n) == 0) ? (1) : ((ll)(log10(double(llabs(n)))) + 1)) - 1);
       i++) {
    m += (ll)((llabs(n) % (ll)(pow(10.0, (double)(i + 1)))) /
              (ll)(pow(10.0, (double)i)));
  }
  return m;
}
ll isP(ll n) {
  if (n <= 1) return 0;
  for (ll i = (2); i <= ((ll)sqrt(n)); i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}
vll FactM(1, 1);
vll FactMI(1, 1);
ll PowM(ll a, ll b) {
  ll ans = 1, x = (a % MOD);
  for (ll i = (0);
       i <= (((llabs(b) == 0) ? (1) : ((ll)(log2(double(llabs(b)))) + 1)) - 1);
       i++) {
    if ((((b) >> (i)) & 1) == 1) ans = (ans * x) % MOD;
    if (i != (((llabs(b) == 0) ? (1) : ((ll)(log2(double(llabs(b)))) + 1)) - 1))
      x = (x * x) % MOD;
  }
  return ans;
}
void CFactM(ll n) {
  if (FactM.size() <= n) {
    for (ll i = (FactM.size()); i <= (n); i++) {
      FactM.push_back((FactM[i - 1] * (i % MOD)) % MOD);
    }
  }
  return;
}
void CFactMI(ll n) {
  CFactM(n);
  if (FactMI.size() < (n + 1)) FactMI.resize(n + 1, -1);
  if (FactMI[n] == -1) FactMI[n] = PowM(FactM[n], MOD - 2);
  for (ll i = (n - 1); i >= (1); i--) {
    if (FactMI[i] != -1) break;
    FactMI[i] = ((FactMI[i + 1] * ((i + 1) % MOD)) % MOD);
  }
  return;
}
ll CombM(ll n, ll k) {
  if ((n < 0) || (k < 0)) return 0;
  if (n < k) return 0;
  if (n + 1 > FactMI.size()) CFactMI(n);
  return ((((FactMI[k] * FactMI[n - k]) % MOD) * FactM[n]) % MOD);
}
ll LIS(vll v, ll m) {
  if (v.size() > 0) {
    ll ans = 0;
    vll dp(v.size(), INF);
    for (ll i = (0); i <= (v.size() - 1); i++) {
      dp[m ? (upper_bound((dp).begin(), (dp).end(), (v[i])) - (dp).begin())
           : (lower_bound((dp).begin(), (dp).end(), (v[i])) - (dp).begin())] =
          v[i];
    }
    for (ll i = (0); i <= (v.size() - 1); i++) {
      if (dp[i] == INF) break;
      ans++;
    }
    return ans;
  } else {
    return 0;
  }
}
signed main() {
  ll n, r = 0, aa, c = 0, b = 0;
  vll a;
  cin >> n;
  a.push_back(0);
  for (ll i = 1; i <= (n); i++) {
    cin >> aa;
    a.push_back(aa + a[i - 1]);
  }
  sort((a).begin(), (a).end());
  for (ll i = 0; i < (n); i++) {
    if (a[i] == b) {
      c++;
      r += c;
    } else {
      b = a[i];
      c = 0;
    }
  }
  cout << r;
  return 0;
}
