#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
long long mod = 1000000007;
long long a[200005];
long long b[200005];
void solve() {
  long long n;
  cin >> n;
  for (long long i = int(1); i < int(n + 1); i++) cin >> a[i];
  long long sum = 0;
  map<long long, long long> its;
  long long ans = 0;
  long long last = 0;
  its[0] = 0;
  for (long long i = int(1); i < int(n + 1); i++) {
    sum += a[i];
    if (its.find(sum) != its.end()) {
      last = max(last, its[sum] + 1);
    }
    its[sum] = i;
    ans += i - last;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
