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