#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n;
long long a[N], pref[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];
    pref[i] = pref[i - 1] + a[i];
  }
  long long last = 0, ans = 0;
  map<long long, long long> idx;
  idx[0] = 0;
  for (long long i = 1; i <= n; i++) {
    if (idx.count(pref[i])) last = max(last, idx[pref[i]] + 1);
    ans += max(0LL, i - last);
    idx[pref[i]] = i;
  }
  cout << ans;
  return 0;
}
