#include <bits/stdc++.h>
using namespace std;
long long ans;
long long start = 0;
void findSubArrays(vector<long long> &arr, long long n) {
  map<long long, set<long long> > map;
  map[0].insert(-1);
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += arr[i];
    if (map.find(sum) != map.end()) {
      auto val = prev(map[sum].end());
      if (start <= *val + 1) {
        ans += (*val + 1 - start + 1) * (n - i);
        start = *val + 2;
      }
    }
    map[sum].insert(i);
  }
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long arr[] = {0, 0, 0, 0, 0};
  findSubArrays(v, n);
  long long tot = ((n) * (n + 1)) / 2;
  cout << tot - ans << endl;
  return 0;
}
