#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    if (i) os << ", ";
    os << v[i];
  }
  os << "}";
  return os;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
bool cmp(const pair<long long, long long>& a,
         const pair<long long, long long>& b) {
  if (a.first == b.first) return (a.second >= b.second);
  return (a.first < b.first);
}
vector<long long> primes;
void Seive(long long n) {
  vector<long long> seive;
  seive.resize(n + 5, 1);
  seive[1] = 0, seive[0] = 0;
  for (int i = 2; i * i < n + 5; i++) {
    if (seive[i]) {
      for (long long(j) = i * i; (j) < (n + 5); (j) += (i)) {
        seive[j] = 0;
      }
    }
  }
}
long long power(long long x, long long y, long long m = 1000000007) {
  long long int res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) res = (res * x) % m;
    y = y >> 1;
    x = (x * x) % m;
  }
  return res;
}
vector<pair<int, int>> findSubArrays(long long arr[], int n) {
  unordered_map<int, vector<int>> map;
  vector<pair<int, int>> out;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0) out.push_back(make_pair(0, i));
    if (map.find(sum) != map.end()) {
      vector<int> vc = map[sum];
      for (auto it = vc.begin(); it != vc.end(); it++)
        out.push_back(make_pair(*it + 1, i));
    }
    map[sum].push_back(i);
  }
  return out;
}
void print1(vector<pair<int, int>> out) {
  for (auto it = out.begin(); it != out.end(); it++)
    cout << "Subarray found from Index " << it->first << " to " << it->second
         << endl;
}
long long modinv(long long x, long long mod = 1000000007) {
  return power(x, mod - 2, mod);
}
int n, m;
long long A[300060];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k, t, a, b, c, d;
  t = 1;
  while (t--) {
    cin >> n;
    for (long long(i) = 1; (i) <= (n); ++(i)) cin >> A[i];
    map<long long, long long> M;
    long long sum = 0, last = 0, ans = 0;
    M[0] = 0;
    for (long long(i) = 1; (i) <= (n); ++(i)) {
      sum += A[i];
      if (M.find(sum) != M.end()) {
        last = max(last, M[sum] + 1);
        M[sum] = i;
      }
      ans += (i - last);
      M[sum] = i;
    }
    cout << ans << endl;
  }
}
