#include <bits/stdc++.h>
using namespace std;
long long a[300000];
int main() {
  map<long long, long long> mp;
  mp[0] = 0;
  long long re = 0, s = 0, ma = -1;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) {
    s += a[i];
    if (mp[s] || s == 0) ma = max(ma, mp[s]);
    mp[s] = i + 1;
    re -= (ma + 1);
  }
  re += n * (n + 1) / 2;
  cout << re;
}
