#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  vector<ll> sum(n + 1);
  for (int i = 0; i < (int)(n); i++) {
    sum.at(i + 1) = sum.at(i) + a.at(i);
  }
  map<ll, ll> nums;
  for (int i = 0; i < (int)(n + 1); i++) nums[sum[i]]++;
  ll ans = 0;
  for (auto it : nums) {
    ll num = it.second;
    ans += num * (num - 1) / 2;
  }
  cout << ans << endl;
}
