#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    long long int n, sum = 0, ans = 0, mx = 0, x;
    cin >> n;
    map<long long int, long long int> m;
    m[0] = -1;
    long long int one = 1;
    for (long long int i = 1; i <= n; i++) {
      cin >> x;
      sum += x;
      if (m.find(sum) != m.end()) {
        if (sum == 0 && m[0] == -1) {
          mx = max(mx, one);
        } else {
          mx = max(mx, m[sum] + 1);
        }
      }
      m[sum] = i;
      ans += i - mx;
    }
    cout << ans;
  }
  return 0;
}
