#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long combination(int n, int k, int init_max_n = -1) {
  static vector<long long> fac, finv, inv, big_n_tbl;
  static const int mod = 1e9 + 7;
  static bool big_n = false;
  static bool created = false;
  if (big_n)
    cerr << "big_n: trueのため、nは初期化時に使用した値になります"
         << "\n";
  if (created && init_max_n != -1)
    cerr << "初期化済みのためinit_max_nの値は無視されます"
         << "\n";
  if (!created) {
    if (init_max_n == -1) {
      cerr << "初期化に失敗しました。"
           << "\n";
      exit(1);
    }
    if (max(init_max_n, n) < 1e7 + 1) {
      fac.resize(init_max_n, 0);
      finv.resize(init_max_n, 0);
      inv.resize(init_max_n, 0);
      fac[0] = fac[1] = 1;
      finv[0] = finv[1] = 1;
      inv[1] = 1;
      for (int i = 2; i < init_max_n; i++) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
      }
    } else {
      chmin(k, n - k);
      big_n_tbl.resize(k + 1, 1);
      inv.resize(k + 2, 1);
      for (int i = (1); i < (k + 1); ++i) {
        inv[i + 1] = mod - inv[mod % (i + 1)] * (mod / (i + 1)) % mod;
        big_n_tbl[i] =
            (i == 1) ? n : ((n - i + 1) * inv[i]) % mod * big_n_tbl[i - 1];
        if (i == 1) cerr << "i:1 " << big_n_tbl[i] << "\n";
        big_n_tbl[i] %= mod;
      }
      big_n = true;
    }
    created = true;
  }
  if (big_n) return big_n_tbl[k];
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
void solve() {
  const int MAX = 1e6;
  combination(MAX, 1, MAX);
  int N;
  cin >> N;
  vector<int> rui(N, 0);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    int A;
    cin >> A;
    if (i == 0)
      rui[i] = A;
    else
      rui[i] = A + rui[i - 1];
  }
  map<int, int> mp;
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    if (!mp.count(rui[i])) mp[rui[i]] = 0;
    mp[rui[i]]++;
  }
  long long ans = 0;
  for (const auto &p : mp) {
    auto [v, cnt] = p;
    if (v == 0)
      ans += combination(cnt + 1, 2);
    else if (cnt > 1)
      ans += combination(cnt, 2);
  }
  cout << ans << "\n";
}
int main() {
  solve();
  return 0;
}
