P2371
Step 1
Observation: Let the smallest non-zero element be \(m\). If \(x = km + b\) is reachable, then every \(x = k'x + b\, (k' \ge k)\) is also reachable.
We can record the minimum \(k\) to reach every \(0 \le b < m\). Everything afterwards is trivial.