#include <bits/stdc++.h>
using namespace std;
int n, f[200010];
long long a[200010], sum[200010];
map<long long, int> m;
int main(void) {
  scanf("%d", &n);
  int i, j;
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    sum[i] = sum[i - 1] + a[i];
  }
  m[0] = 0;
  f[0] = -1;
  for (i = 1; i <= n; i++) {
    long long x = sum[i];
    if (!m.count(x)) {
      f[i] = f[i - 1];
    } else {
      f[i] = max(f[i - 1], m[x]);
    }
    m[x] = i;
  }
  long long ans = 0;
  for (i = n; i >= 1; i--) {
    j = f[i];
    ans += i - j - 1;
  }
  printf("%I64d\n", ans);
  return 0;
}
