#include <bits/stdc++.h>
long long powermod(long long _a, long long _b, long long _m) {
  long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
using namespace std;
template <typename T>
void pr(const T& t) {
  cout << t << "\n";
}
template <typename T, typename U, typename... ARGS>
void pr(const T& t, const U& u, const ARGS&... args) {
  cout << t << " ";
  pr(u, args...);
}
long long calc(long long a, long long b) {
  b++;
  return ((b - a) * (b - a + 1)) / 2;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  long long n;
  cin >> n;
  ;
  long long arr[n];
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  ;
  map<long long, long long> mp;
  long long sum[n], cnt = 0;
  mp[0] = -1;
  long long maxx = -1;
  for (long long i = 0; i < n; ++i) {
    cnt += arr[i];
    if (mp.find(cnt) != mp.end()) maxx = max(maxx, mp[cnt] + 1);
    sum[i] = i - maxx;
    mp[cnt] = i;
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) ans += sum[i];
  pr(ans);
}
