#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
long long sum[maxn];
map<long long, long long> mp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  mp.clear();
  mp[0] = 0;
  long long n, p = -1, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> sum[i];
    sum[i] += sum[i - 1];
    if (mp.count(sum[i])) p = max(p, mp[sum[i]]);
    mp[sum[i]] = i;
    ans += i - p - 1;
  }
  cout << ans;
  return 0;
}
