#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(int argc, char** argv) {
  int n;
  cin >> n;
  vector<ll> a(n + 3);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vector<ll> cum_S(n + 1, 0);
  for (int i = 0; i < n; ++i) cum_S[i + 1] = cum_S[i] + a[i];
  map<ll, ll> count;
  for (int i = 0; i < n + 1; ++i) ++count[cum_S[i]];
  int ans{0};
  for (auto& e : count) {
    ll tmp = e.second;
    ans += tmp * (tmp - 1) / 2;
  }
  std::cout << ans << std::endl;
}
