#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 51123987;
const int N = 7 + 2e5;
int n;
long long a[N];
long long pre[N];
map<long long, int> dic;
long long ans;
int main() {
  scanf("%d", &n);
  dic[0] = 0;
  int lst = 0;
  for (int i = 1; i <= n; ++i) {
    scanf("%lld", a + i);
    pre[i] = pre[i - 1] + a[i];
    if (dic.count(pre[i])) lst = max(lst, dic[pre[i]] + 1);
    ans += i - lst;
    dic[pre[i]] = i;
  }
  printf("%lld\n", ans);
  return 0;
}
