#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e9;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  long long sum = 0, cnt = 0, last = 0;
  map<long long, long long> m;
  m.insert(make_pair(0, 0));
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    sum += a[i];
    if (m.find(sum) != m.end()) {
      last = max(last, m[sum] + 1);
      m[sum] = i;
    } else {
      m.insert(make_pair(sum, i));
    }
    if (a[i] == 0) {
      last = i;
      m[0] = i;
    }
    cnt += i - last;
  }
  cout << cnt << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
