#include <bits/stdc++.h>
const long double PI = acos(-1);
using namespace std;
inline long long mod(long long n, long long m = 1000000007) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long exp(long long n, long long k) {
  if (k == 0) return 1;
  if (k == 1) return n;
  long long ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2) ax = mod(ax * n);
  return ax;
}
long long gcd(long long a, long long b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
struct PreffixStructure {
  vector<long long> pre;
  PreffixStructure(const vector<long long> &v) {
    pre.resize(v.size() + 1, 0);
    for (long long i = 1; i <= v.size(); i++) {
      pre[i] = pre[i - 1] + v[i - 1];
    }
  }
  long long get(long long l, long long r) { return pre[r] - pre[l - 1]; }
  long long get(long long l) { return pre[l]; }
};
void solution() {
  long long n;
  cin >> n;
  long long acc = 0;
  set<long long> s;
  long long ans = 0;
  long long pt = 0;
  long long v[n + 1];
  v[0] = 0;
  for (long long i = 1; i <= n; i++) cin >> v[i], v[i] += v[i - 1];
  s.insert(0);
  for (long long i = 0; i <= n; i++) {
    while (pt < n && !s.count(v[pt + 1])) {
      s.insert(v[pt + 1]);
      pt++;
    }
    ans += pt - i;
    s.erase(s.find(v[i]));
  }
  cout << ans << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  long long t = 1;
  while (t--) solution();
}
