#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
map<long long, long long> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long i, n, mx = 0, s = 0, l, ans = 0;
  mp[0] = 1;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> l;
    s += l;
    mx = max(mx, mp[s]);
    ans += (i - mx);
    mp[s] = i + 1;
  }
  cout << ans << "\n";
  return 0;
}
