#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2e5 + 10;
long long a[maxn], p[maxn];
map<long long, long long> M;
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) p[i] = p[i - 1] + a[i];
  long long res = 0, lst = -1, other = -1;
  M[0] = 0;
  for (long long i = 1; i <= n; i++) {
    long long here;
    if (M.count(p[i]) == 0)
      here = max(lst, -1LL);
    else
      here = max(lst, M[p[i]]);
    if (M.count(p[i])) other = max(other, M[p[i]]);
    here = max(here, other);
    res += i - (here + 1);
    M[p[i]] = i;
    if (a[i] == 0) lst = i - 1;
  }
  cout << res << endl;
  return 0;
}
