#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
void solve() {
  int n;
  cin >> n;
  VI a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  VI minus(n, 0), plus(n, 0);
  bool check = true;
  for (int i = 0; i < n; ++i) {
    if (i) {
      plus[i] |= plus[i - 1];
      minus[i] |= minus[i - 1];
    }
    if (a[i] < b[i]) {
      if (plus[i] == 0) {
        check = false;
      }
    }
    if (a[i] > b[i]) {
      if (minus[i] == 0) {
        check = false;
      }
    }
    if (a[i] < 0) {
      minus[i] = 1;
    }
    if (a[i] > 0) {
      plus[i] = 1;
    }
  }
  if (check) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
LL cnt(LL x) { return x * (x + 1) / 2; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(nullptr);
  int n;
  cin >> n;
  VI a(n + 1);
  map<LL, int> mep;
  LL sum = 0, ans = 0;
  mep[0] = -1;
  int q = -2;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
    if (mep.count(sum)) {
      q = max(q, mep[sum]);
    }
    ans += i - q - 1;
    mep[sum] = i;
  }
  cout << ans << "\n";
  return 0;
}
