# Clue Generator: Solution Problem setter's solution: compress prefix sums, precompute equal-value counts and index sums by blocks, and handle full blocks plus two fringes during queries. Codex (GPT-6) contributed complete block-interval answers, compact storage using occurrence-list prefix sums, proofs and standard C++17 implementation. Prefix sums, block decomposition and coordinate compression are classical methods. ## Distances between equal prefix values Let $P_0=0$ and $P_i=\sum_{j=1}^i a_j$ . A subarray $[s,t]$ has sum zero exactly when $P_{s-1}=P_t$ , and its length is $t-(s-1)$ . A query $[l,r]$ therefore asks for the total distance $j-i$ of all equal-value pairs $i