#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
long long o[200100], ans;
int main(void) {
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &o[i]);
    o[i] += o[i - 1];
  }
  long long lim = -1;
  for (long long i = 0; i <= n; i++) {
    if (mp.count(o[i])) lim = max(lim, mp[o[i]]);
    ans += i - lim - 1;
    mp[o[i]] = i;
  }
  printf("%lld\n", ans);
}
