#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
template <typename T>
inline T read() {
  T ans = 0, flag = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ans = ans * 10 + c - 48;
    c = getchar();
  }
  return ans * flag;
}
int n, a[maxn];
long long s[maxn];
map<long long, int> cnt;
int main() {
  n = read<int>();
  for (register int i(1), end_i(n); i <= end_i; i++)
    s[i] = s[i - 1] + (a[i] = read<int>());
  cnt[0] = 1;
  int j = 0;
  long long ans = 0;
  for (register int i(1), end_i(n); i <= end_i; i++) {
    cnt[s[i]]++;
    while (cnt[s[i]] > 1) cnt[s[j++]]--;
    ans += i - j;
  }
  cout << ans << endl;
  return 0;
}
