fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4. #define sep ios::sync_with_stdio(0),cin.tie(0)
  5. const ll MXi = 1e5 + 5;
  6. int main() {
  7. sep;
  8. ll n, su = 0, tmp = 0, x; cin >> n;
  9. ll res = n*(n+1)/2;
  10. unordered_map<ll, ll> seen;
  11. seen[0] = 1;
  12. for (ll i = 0; i < n; ++i) {
  13. cin >> x;
  14. su+= x;
  15. ++seen[su];
  16. }
  17. for (auto X: seen)
  18. res-= (X.second*(X.second-1)/2);
  19. cout << res << "\n";
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 6464KB
stdin
Standard input is empty
stdout
2642899456