#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T&&... args) {
  ((cout << args << " "), ...);
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, ans(0);
  read(n);
  vector<long long> arr(n + 1, 0);
  for (long long i = 1; i < n + 1; ++i) {
    read(arr[i]);
    arr[i] += arr[i - 1];
  }
  long long start(0), end(0);
  set<long long> s = {0};
  while (start < n) {
    while (end < n && !s.count(arr[end + 1])) {
      ++end;
      s.insert(arr[end]);
    }
    ans += end - start;
    s.erase(arr[start]);
    ++start;
  }
  cout << ans << '\n';
  arr.clear();
  s.clear();
  return 0;
}
