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