#include <bits/stdc++.h>
using namespace std;
int a[200009], b[200009], z[200009];
long long sum[200009];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[i] = sum[i - 1] + a[i];
  map<long long, int> mp;
  long long ans = 0;
  int l = 0;
  mp[0] = 1;
  for (int i = 1; i <= n; i++) {
    while (mp[sum[i]]) mp[sum[l++]]--;
    mp[sum[i]]++;
    ans += (i - l);
  }
  printf("%lld\n", ans);
  return 0;
}
