#include <bits/stdc++.h>
int _ = (std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
         std::cout.precision(10), std::cout.setf(std::ios::fixed));
using ll = long long;
using ld = long double;
using namespace std;
ll fact(ll n) {
  if (n <= 0) {
    return 1;
  }
  ll acc = 1;
  for (int i = 1; i <= n; i++) {
    acc = acc * i;
  }
  return acc;
}
ll comb(ll n, ll r) { return fact(n) / (fact(n - r) * fact(r)); }
int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (int i = (0); i < int(N); ++i) {
    cin >> A[i];
  }
  vector<ll> cs(N + 1, 0);
  cs[0] = 0;
  for (int i = 1; i <= N; i++) {
    cs[i] = cs[i - 1] + A[i - 1];
  }
  map<ll, ll> m;
  for (int i = 0; i <= N; i++) {
    m[cs[i]] = m[cs[i]] + 1;
  }
  ll answer = 0;
  for (const auto &kv : m) {
    if (kv.second >= 2) {
      answer += comb(kv.second, 2);
    }
  }
  cout << answer << endl;
  return 0;
}
