#include <bits/stdc++.h>
using namespace std;
int n;
long long ans = 0;
map<long long, int> last;
int main() {
  int i, x, z = 0;
  long long y = 0;
  scanf("%d", &n);
  last[0] = 0;
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    y += x;
    if (last.count(y))
      if (last[y] + 1 > z) z = last[y] + 1;
    last[y] = i;
    ans += i - z;
  }
  printf("%lld", ans);
  return 0;
}
