#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  vector<int> ac(n + 1, 0);
  map<int, int> mp;
  mp[0]++;
  for (int i = 0; i < n; i++) {
    ac[i + 1] = ac[i] + a[i];
    mp[ac[i + 1]]++;
  }
  int ans = 0;
  for (int i = 0; i < n + 1; i++) {
    ans += max(0, --mp[ac[i]]);
  }
  cout << ans << endl;
  return 0;
}
