#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v(n + 1, 0);
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    int x;
    cin >> x;
    v[i + 1] = v[i] + x;
  }
  long long ans = 0;
  set<long long> s = {0};
  long long end = 0, begin = 0;
  while (begin < n) {
    while (end < n && !s.count(v[end + 1])) {
      end++;
      s.insert(v[end]);
    }
    ans += end - begin;
    s.erase(v[begin]);
    begin++;
  }
  cout << ans;
  return 0;
}
