#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using vvv = vector<vector<vector<ll>>>;
using edge = struct {
  int to;
  int cost;
};
bool pairCompare(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * POW(n, m - 1)) % MOD;
  }
}
ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll C(int n, int m) { return (P(n, n - m) * POW(factorial(m), MOD - 2)) % MOD; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  ll N;
  cin >> N;
  map<ll, ll> M;
  vector<ll> A(N, 0);
  ll S = 0;
  for (ll i = 0; i < (N); i++) cin >> A[i];
  S = A[0];
  M[S] = 1;
  for (ll i = (1); i < (N); i++) {
    S = S + A[i];
    if (M.find(S) != M.end())
      M[S] = M[S] + 1;
    else
      M[S] = 1;
  }
  ll ans = 0;
  for (auto &m : M) {
    if (m.first == 0) {
      ans += C(m.second + 1, 2);
    } else if (m.second >= 2) {
      ans += C(m.second, 2);
    }
  }
  cout << ans << endl;
  return 0;
}
