#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) a[i + 1] += a[i];
  map<ll, int> m;
  for (int i = 0; i <= n; i++) m[a[i]]++;
  ll ans = 0;
  for (auto p : m) {
    ans += p.second * (p.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
