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