#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read() {
  T x = 0, f = 0;
  char c = getchar();
  while (!isdigit(c)) f = c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const long long N = 2e5 + 9;
map<long long, long long> mp;
long long n, a[N], ans;
long long main() {
  n = read<long long>();
  for (long long i = 1; i <= n; i++) a[i] = read<long long>();
  mp[0] = 1;
  for (long long i = 1, sum = 0, las = 0; i <= n; i++) {
    sum += a[i];
    las = max(las, mp[sum]);
    ans += i - las;
    mp[sum] = i + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
}  // namespace run
int main() { return run::main(); }
