#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n;
long long a[N];
map<long long, long long> mp;
long long zero[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  mp[0] = 0;
  long long pref = 0;
  for (long long i = 1; i <= n; i++) {
    pref += a[i];
    zero[i] = n + 1;
    if (mp.find(pref) != mp.end()) zero[mp[pref] + 1] = i;
    if (a[i] == 0) zero[i] = i;
    mp[pref] = i;
  }
  long long ans = 0, curr_bound = n + 1;
  for (long long i = n; i >= 1; i--) {
    long long l = i;
    long long r = min(zero[i], curr_bound);
    ans += (r - l);
    curr_bound = r;
  }
  cout << ans;
  return 0;
}
