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