#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long tc;
  long long n, b, ans = 0, k, d, m;
  cin >> n;
  vector<long long> v(n + 1);
  map<long long, long long> mp;
  v[0] = 0;
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    v[i] = v[i - 1] + x;
  }
  for (long long i = 0, j = 0; i <= n; i++) {
    mp[v[i]]++;
    while (mp[v[i]] > 1) {
      mp[v[j++]]--;
    }
    ans += (i - j);
  }
  cout << ans << endl;
}
