#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long neg = 1, num = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - '0';
  return neg * num;
}
long long T, n, m, ans;
map<long long, long long> used, cnt;
signed main() {
  n = read();
  ans = n * (n + 1) / 2;
  long long s = 0;
  used[0] = 0;
  cnt[s] = 1;
  long long las = -1;
  for (long long i = 1; i <= n; i++) {
    long long a = read();
    s += a;
    if (cnt[s] != 0) las = max(las, used[s]);
    used[s] = i;
    cnt[s]++;
    ans -= las + 1;
  }
  printf("%lld", ans);
  return 0;
}
