#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void prn(vector<T>& v) {
  int n = (int)v.size();
  for (int i = (0); i < ((n)); i++) cout << v[i] << ' ';
}
template <class T>
inline void printv(vector<T>& v) {
  int n = (int)v.size();
  for (int i = (0); i < ((n)); i++) cout << v[i] << (i == n - 1 ? '\n' : ' ');
}
template <class T>
inline void printvv(vector<vector<T>>& v) {
  for (auto u : v) printv(u);
}
template <class T>
inline void printlnv(vector<T>& v) {
  int n = (int)v.size();
  for (int i = (0); i < ((n)); i++) cout << v[i] << '\n';
}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
void solve();
int main() {
  cout << fixed << setprecision(numeric_limits<double>::max_digits10);
  solve();
  return 0;
}
class Combination {
  vector<ll> factorial;
  vector<ll> fact_inverse;
  vector<ll> inverse;
  int mod;
  void init(int size) {
    factorial[0] = 1;
    factorial[1] = 1;
    fact_inverse[0] = 1;
    fact_inverse[1] = 1;
    inverse[1] = 1;
    for (int i = 2; i < size; i++) {
      factorial[i] = factorial[i - 1] * i % mod;
      inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
      fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
    }
  }

 public:
  Combination(int size, int m) {
    factorial = vector<ll>(size);
    fact_inverse = vector<ll>(size);
    inverse = vector<ll>(size);
    mod = m;
    init(size);
  }
  ll calc(int n, int k) {
    if (n < k) {
      return 0;
    }
    if (n < 0 || k < 0) {
      return 0;
    }
    return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
  }
  ll with_repetition(int n, int k) { return calc(n + k - 1, k); }
};
vector<vector<ll>> pascals_triangle(int n) {
  vector<vector<ll>> combi(n + 1, vector<ll>(n + 1));
  for (int i = (0); i < ((n + 1)); i++)
    for (int j = (0); j < ((i + 1)); j++) {
      if (j == 0 || j == i)
        combi[i][j] = 1LL;
      else
        combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
    }
  return combi;
}
void solve() {
  int n;
  cin >> n;
  vl sum(n + 1);
  ll a;
  for (int i = (0); i < ((n)); i++) {
    cin >> a;
    sum[i + 1] = sum[i] + a;
  }
  map<ll, int> m;
  for (int i = (0); i < ((n + 1)); i++) m[sum[i]]++;
  ll ans = 0;
  for (auto p : m) ans += p.second * (p.second - 1) / 2;
  cout << ans << '\n';
}
