#include <bits/stdc++.h>
using namespace std;
long long n, q, s, ans;
map<long long, long long> pos;
int main() {
  cin >> n;
  pos[0] = 0;
  long long q = -1;
  for (int i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    s += x;
    if (pos.count(s)) q = max(q, pos[s]);
    ans += i - q - 1;
    pos[s] = i;
  }
  cout << ans << '\n';
  return 0;
}
