#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
const long long LLINF = (1LL << 60);
const long long INF = (1LL << 30);
const double DINF = std::numeric_limits<double>::infinity();
const long long MOD = 1000000007;
const long long MAX_N = 100010;
signed main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> cs(N);
  for (long long i = 0; i < N; ++i) {
    cin >> A[i];
    if (i == 0) {
      cs[i] = A[i];
    } else {
      cs[i] = cs[i - 1] + A[i];
    }
  }
  long long ans = 0;
  map<long long, long long> cnt;
  for (long long i = N - 1; i >= 0; --i) {
    long long val = cs[i] - A[i];
    if (cnt.count(val) > 0) {
      ans += cnt[val];
    }
    cnt[cs[i]]++;
  }
  printf("%lld\n", ans);
  return 0;
}
