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