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