#include <bits/stdc++.h>
long long int gcd(unsigned long long int a, unsigned long long int b) {
  return (a == 0) ? b : gcd(b % a, a);
}
long long int lcm(unsigned long long int a, unsigned long long int b) {
  return a * (b / gcd(a, b));
}
int kx[8] = {+2, +2, -2, -2, +1, +1, -1, -1};
int ky[8] = {+1, -1, +1, -1, +2, -2, +2, -2};
int d9x[9] = {+1, +1, +1, +0, +0, +0, -1, -1, -1};
int d9y[9] = {+1, +0, -1, +1, +0, -1, +1, +0, -1};
int dx4[4] = {0, 0, +1, -1};
int dy4[4] = {+1, -1, 0, 0};
using namespace std;
long long int tri(int n) { return (n * n - n) / 2; }
int main() {
  int n;
  cin >> n;
  long long int a[n + 1];
  long long int b[n + 1];
  a[0] = 0;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  b[0] = 0;
  for (int i = 1; i <= n; ++i) b[i] = b[i - 1] + a[i];
  set<long long int> S;
  S.insert(b[0]);
  long long int l = 0;
  long long int r = 0;
  long long int R[n];
  while (r < n) {
    auto x = S.find(b[r + 1]);
    if (x == S.end()) {
      ++r;
      S.insert(b[r]);
    } else {
      R[l] = r;
      S.erase(S.find(b[l]));
      ++l;
    }
  }
  while (l <= n) {
    R[l] = r;
    ++l;
  }
  long long int ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += R[i] - i;
  }
  cout << ans << endl;
}
