#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  vector<long long> A(n + 1), psum(n + 1);
  psum[0] = 0;
  for (long long i = 1; i <= n; i++) {
    cin >> A[i];
    psum[i] = psum[i - 1] + A[i];
  }
  map<long long, long long> mp;
  mp[0] = 0;
  long long last = 0, baby = 0;
  for (long long i = 1; i <= n; i++) {
    if (mp.find(psum[i]) != mp.end()) {
      last = max(last, mp[psum[i]] + 1);
    }
    baby += max(0LL, i - last);
    mp[psum[i]] = i;
  }
  cout << baby;
  return 0;
}
