#include <bits/stdc++.h>
using namespace std;
map<long long, long long> m;
long long sum[300000];
int a[300000];
int n;
long long ans = 0, cnt = 0;
void solve() {
  for (int i = 1; i <= n; i++) {
    sum[i] = sum[i - 1] + a[i];
    int h = m.count(sum[i]);
    if (h) cnt = max(cnt, m[sum[i]] + 1);
    ans += i - cnt;
    m[sum[i]] = i;
  }
  printf("%lld", ans);
}
int main() {
  m[0] = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  solve();
  return 0;
}
