#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MAX_N = 1e5;
int a[MAX_N];
ll s[MAX_N + 1];
int main() {
  int N;
  cin >> N;
  for (int i{}; i < N; ++i) cin >> a[i];
  for (int i{}; i < N; ++i) {
    s[i + 1] = s[i] + a[i];
  }
  map<ll, int> num;
  for (int i{}; i <= N; ++i) {
    ++num[s[i]];
  }
  ll ans{};
  for (const auto& p : num) {
    if (p.second <= 1) continue;
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
