#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
void print() {}
template <class H, class... T>
void print(H&& h, T&&... t) {
  cout << h << " \n"[sizeof...(t) == 0];
  print(forward<T>(t)...);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin >> N;
  ll a[200010];
  for (ll i = (0); i < (N); i++) cin >> a[i];
  ll sum[200010] = {};
  for (ll i = (0); i < (N); i++) sum[i + 1] = sum[i] + a[i];
  map<ll, ll> mp;
  ll ans = 0;
  mp[0] = 1;
  ll last_pos = -1;
  for (ll i = (1); i < (N + 1); i++) {
    if (mp[sum[i]] == 0) {
      if (last_pos == -1) {
        ans += i;
      } else {
        ans += i - last_pos - 1;
      }
    } else {
      if (last_pos == -1) {
        ans += i - mp[sum[i]];
        last_pos = mp[sum[i]] - 1;
      } else {
        ll pos = max(last_pos, mp[sum[i]] - 1);
        last_pos = pos;
        ans += i - pos - 1;
      }
    }
    mp[sum[i]] = i + 1;
  }
  print(ans);
}
