#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
int main() {
  int n;
  cin >> n;
  vl s(n + 1, 0);
  ll tmp;
  map<ll, int> mp;
  for (int(i) = (0); (i) < (n); (i)++) {
    cin >> tmp;
    s[i + 1] = s[i] + tmp;
  }
  for (int(i) = (1); (i) < (n + 1); (i)++) {
    mp[s[i]]++;
  }
  ll ans = 0;
  for (auto e : mp) {
    if (e.first == 0) ans += e.second;
    if (e.second > 1) ans += (e.second) * (e.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
