#include <bits/stdc++.h>
#pragma GCC optimize("O3", "Ofast", "unroll-loops", "fast-math")
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long i, n;
  cin >> n;
  vector<long long> a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long last = 0;
  long long cur = 0;
  long long ans = 0;
  map<long long, long long> m;
  m[0] = -1;
  for (i = 0; i < n; i++) {
    cur += a[i];
    if (m.find(cur) != m.end()) {
      last = max(last, m[cur] + 2);
    }
    if (last <= i) {
      ans += (i - last + 1);
    }
    m[cur] = i;
  }
  cout << ans << '\n';
  return 0;
}
