#include <bits/stdc++.h>
using namespace std;
const long mod = pow(10, 9) + 7;
long long nC2(long long n) {
  if (n <= 1) return 0;
  return (n * (n - 1)) / 2;
}
long long nC3(long long n) {
  if (n <= 2) return 0;
  return (n * (n - 1) * (n - 2)) / 6;
}
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long ans = 0;
  map<long long, long long> mp;
  long long r = 0, maximum = -2;
  mp[0] = -1;
  for (int i = 0; i < n; i++) {
    r += a[i];
    if (mp.find(r) != mp.end()) maximum = max(maximum, mp[r]);
    long long reqVal = i - (maximum + 1);
    ans += reqVal;
    mp[r] = i;
  }
  cout << ans << endl;
  return 0;
}
