#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
long long ar[200005];
long long br[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> ar[i];
    }
    long long prv = 1;
    mp[0] = 0;
    long long ans = 0;
    for (int i = 1; i <= n; i++) {
      br[i] = br[i - 1] + ar[i];
      if (mp.count(br[i])) {
        prv = max(prv, mp[br[i]] + 2);
      }
      ans += i - prv + 1;
      mp[br[i]] = i;
    }
    cout << ans << endl;
  }
}
