#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n - 1);
  return ans * n;
}
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; }
bool is_prime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x * x % mod, n / 2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}
int main() {
  ll n;
  cin >> n;
  vector<ll> v(n + 1, 0);
  map<ll, ll> score;
  score[0] = 1;
  for (int i = 0; i < (int)(n); i++) {
    ll a;
    cin >> a;
    v.at(i + 1) = v.at(i) + a;
    if (score.count(v.at(i + 1))) {
      score.at(v.at(i + 1))++;
    } else {
      score[v.at(i + 1)] = 1;
    }
  }
  ll res = 0;
  for (int i = 0; i < (int)(n + 1); i++) {
    res += score.at(v.at(i)) - 1;
    score.at(v.at(i)) = 1;
  }
  cout << res << endl;
}
