#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  bool f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = 0;
  for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + c - '0';
  if (f) return x;
  return 0 - x;
}
const int maxn = 300000 + 10;
const long long mod = 998244353;
int n;
long long sum, ans;
int pos = -1;
map<long long, int> mp;
int main() {
  n = read();
  mp[0] = 0;
  for (int i = 1, x; i <= n; i++) {
    cin >> x;
    sum += x;
    if (mp.count(sum)) pos = max(pos, mp[sum]);
    ans += i - 1 - pos;
    mp[sum] = i;
  }
  cout << ans << endl;
  return 0;
}
