#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  set<signed long long> s;
  signed long long ans = 0;
  vector<signed long long> sum(n + 1);
  for (int i = 0; i < n; i++) sum[i + 1] = sum[i] + a[i];
  for (int i = 0, j = 0; i <= n; ++i) {
    while (s.count(sum[i])) {
      s.erase(sum[j]);
      ++j;
    }
    s.insert(sum[i]);
    ans += i - j;
  }
  cout << ans << endl;
  return 0;
}
