#include <bits/stdc++.h>
using namespace std;
map<long long, vector<int> > ma;
long long sum[200005], a[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum[i] = sum[i - 1] + a[i];
    ma[sum[i]].push_back(i);
  }
  int r = 1e9;
  for (int i = n; i >= 1; i--) {
    long long t = sum[i] - a[i];
    if (lower_bound(ma[t].begin(), ma[t].end(), i) == ma[t].end()) {
      if (r == 1e9)
        ans += n - i + 1;
      else
        ans += r - i;
    } else {
      ans += min(r, *lower_bound(ma[t].begin(), ma[t].end(), i)) - i;
      r = min(r, *lower_bound(ma[t].begin(), ma[t].end(), i));
    }
  }
  cout << ans << '\n';
  return 0;
}
