#include <bits/stdc++.h>   using namespace std;   long long power(long long x, long long y, long long p) {     long long res = 1;     x = x % p;     while (y > 0) {       if (y & 1) res = (res * x) % p;       y = y >> 1;       x = (x * x) % p;     }     return res;   }   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     long long n;     cin >> n;     long long a[n];     for (long long i = 0; i < n; i++) cin >> a[i];     map<long long, long long> mp;     long long ans = 0;     long long prev = 0;     long long sum = 0;     for (long long i = 0; i < n; i++) {       sum += a[i];       if (sum == 0)         prev = max(prev, mp[0] + 1);       else if (mp.find(sum) != mp.end())         prev = max(prev, mp[sum] + 1);       ans += i + 1 - prev;       mp[sum] = i + 1;     }     cout << ans <<   n ;     return 0;   }   