#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
long long a[maxn], d[maxn];
int main() {
  int n;
  map<long long, long long> M;
  while (~scanf("%d", &n)) {
    M.clear();
    for (int i = 1; i <= n; ++i) {
      scanf("%lld", &a[i]);
    }
    d[0] = 0;
    for (int i = 1; i <= n; ++i) d[i] = d[i - 1] + a[i];
    M[0] = 0;
    long long ans = 0, l_pos = 0;
    for (int i = 1; i <= n; ++i) {
      if (M[d[i]])
        l_pos = max(l_pos, M[d[i]] + 1);
      else if (d[i] == 0)
        l_pos = max(l_pos, 1ll);
      ans += max(0ll, i - l_pos);
      M[d[i]] = i;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
