#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int main() {
  int n;
  cin >> n;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) a[i + 1] += a[i];
  std::map<int, std::vector<int>> mp;
  for (int i = 0; i < n; i++) {
    mp[a[i]].push_back(i);
  }
  long ans = 0;
  for (int i = 0; i < n; i++) {
    int k = upper_bound(begin(mp[a[i]]), end(mp[a[i]]), i) - begin(mp[a[i]]);
    ans += mp[a[i]].size() - k;
  }
  for (int i = 0; i < n; i++)
    if (!a[i]) ans++;
  cout << ans << endl;
  return 0;
}
