#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long ksm(long long a, long long b) {
  if (b < 0) return 0;
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int t;
long long n, m;
long long a, sum[maxn];
int vis[maxn];
int main() {
  scanf("%lld", &n);
  map<long long, long long> mp;
  mp[0] = 1;
  long long ans = 0, mx = 0;
  sum[0] = 0;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a);
    sum[i] = sum[i - 1] + a;
    mx = max(mx, mp[sum[i]]);
    ans += (i - mx);
    mp[sum[i]] = i + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
