#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n + 1];
  for (long int i = 0; i < n; i++) cin >> a[i + 1];
  map<long long int, long long int> m;
  long long int ans = 0;
  long long int l = 0;
  a[0] = 0;
  m[0] = 0;
  for (long int i = 1; i <= n; i++) {
    a[i] += a[i - 1];
    if (m.find(a[i]) != m.end()) {
      l = max(l, m[a[i]] + 1LL);
      ans += (i - l);
      m[a[i]] = i;
    } else {
      m[a[i]] = i;
      ans += (i - l);
    }
  }
  cout << ans << endl;
  return 0;
}
