#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, x;
  cin >> n;
  long long s = 0LL, ans = 0LL;
  int m = 0;
  map<long long, int> M;
  M[0] = 1;
  for (int i = 1; i <= n; ++i) {
    ans += 1LL * i;
    cin >> x;
    s += 1LL * x;
    ans -= m = max(m, M[s]);
    M[s] = i + 1;
  }
  cout << ans;
  return 0;
}
