#include <bits/stdc++.h>
using namespace std;
long long read() {
  char x = getchar();
  long long ans = 0, flag = 1;
  while (!isdigit(x))
    if (x == '-')
      flag = -1, x = getchar();
    else
      x = getchar();
  while (isdigit(x)) ans = ans * 10 + x - '0', x = getchar();
  return ans * flag;
}
long long n, a[200005], ans, las;
map<long long, long long> mp;
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) a[i] += a[i - 1];
  mp[0] = 0;
  las = 0;
  for (long long i = 1; i <= n; i++) {
    if (mp.find(a[i]) != mp.end()) {
      if (mp[a[i]] >= las) {
        ans -= (mp[a[i]] - las + 1) * ((n - i + 1));
        las = mp[a[i]] + 1;
      }
    }
    mp[a[i]] = i;
  }
  cout << ans + n * (n + 1) / 2;
  return 0;
}
