#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const long long inf = 1e9;
const int maxn = 3e5 + 10;
void rmax(long long& r, long long x) { r = max(r, x); }
long long n, k, x, y;
long long a[maxn], b[maxn];
map<long long, long long> m;
int main(void) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  long long ans = 0, sum = 0, j = 0;
  m[0] = 1;
  for (int i = 1; i <= n; ++i) {
    sum += a[i];
    if (m.find(sum) != m.end())
      j = max<long long>(j, m[sum]);
    else
      m[sum] = 0;
    m[sum] = max<long long>(m[sum], i + 1);
    ans += i - j;
  }
  cout << ans;
  return 0;
}
