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