#include <bits/stdc++.h>
using namespace std;
const long long MAXN = (long long)((1e5) + 100);
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a < b)
    return a;
  else
    return b;
}
void pr(long long x) { cout << x; }
void prl(long long x) { cout << x << "\n"; }
long long cbrt(long long x) {
  long long lo = 1, hi = min(2000000ll, x);
  while (hi - lo > 1) {
    long long mid = (lo + hi) / 2;
    if (mid * mid * mid < x) {
      lo = mid;
    } else
      hi = mid;
  }
  if (hi * hi * hi <= x)
    return hi;
  else
    return lo;
}
const long long dx[4] = {-1, 1, 0, 0};
const long long dy[4] = {0, 0, -1, 1};
long long XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};
long long YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};
const long long N = (long long)(2 * 1e5 + 10);
long long spf[N + 5];
void SOF() {
  spf[1] = 1;
  for (long long i = 2; i < N; i++) spf[i] = i;
  for (long long i = 4; i < N; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < N; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < N; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
signed main() {
  SOF();
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long T = 1;
  while (T--) {
    long long n;
    cin >> n;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    map<long long, long long> mpp;
    mpp[0] = -1;
    long long s = 0;
    long long cnt = 0;
    long long last = -1;
    for (long long i = 0; i < n; i++) {
      s += a[i];
      if (mpp.find(s) != mpp.end()) {
        last = max(last, mpp[s] + 1);
      }
      cnt += max(0, i - last);
      mpp[s] = i;
    }
    cout << cnt;
  }
}
