#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int t[n];
  for (int i = 0; i < n; ++i) cin >> t[i];
  map<long long int, int> m;
  map<long long int, int>::iterator it;
  long long int sm = 0, res = 0;
  m.insert(pair<long long int, int>(0, -1));
  int j = -2;
  for (int i = 0; i < n; ++i) {
    sm += t[i];
    it = m.find(sm);
    if (it == m.end()) {
      res += (i - (j + 1));
      m.insert(pair<long long int, int>(sm, i));
    } else {
      j = max(j, it->second);
      res += (i - (j + 1));
      it->second = i;
    }
  }
  cout << res;
}
