#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = (0); i < (n); i++) cin >> a[i];
  vector<ll> s(n + 1);
  s[0] = 0;
  for (int i = (0); i < (n); i++) s[i + 1] = s[i] + a[i];
  sort(s.begin(), s.end());
  ll ans = 0;
  for (int i = 0; i < s.size();) {
    ll now = s[i];
    int cnt = 0;
    for (i; i < s.size() and s[i] == now; i++) ++cnt;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
