#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> pr = vector<long long>();
  pr.push_back(0);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    pr.push_back(pr[i] + a);
  }
  long long cnt = 0;
  set<long long> s = set<long long>();
  s.insert(0);
  int begin = 0, end = 0;
  while (begin < n) {
    while (end < n && !s.count(pr[end + 1])) {
      end++;
      s.insert(pr[end]);
    }
    cnt += end - begin;
    s.erase(pr[begin]);
    begin++;
  }
  cout << cnt << '\n';
  return 0;
}
