#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
long long a;
map<long long, long long> mp;
long long n;
int main() {
  scanf("%lld", &n);
  long long sum = 0, ans = 0;
  mp[0] = 0;
  long long last = 0;
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a);
    sum += a;
    if (mp.find(sum) != mp.end()) last = max(last, mp[sum] + 1);
    ans += i - last;
    mp[sum] = i;
  }
  cout << ans << endl;
  return 0;
}
