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