#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const long long int N = 100005;
void solve() {
  long long int i, j, k, n, m, ans = 0, cnt = 0, sum = 0;
  cin >> n;
  long long int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<long long int, long long int> mp;
  sum = -1;
  mp[0] = -1;
  for (i = 0; i < n; i++) {
    ans += i + 1;
    cnt += a[i];
    if (mp.count(cnt)) {
      sum = max(mp[cnt] + 1, sum);
    }
    ans -= sum + 1;
    mp[cnt] = i;
  }
  cout << ans << '\n';
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
