[edit] 10852 - Less Prime
[edit] Summary
Pretty straightforward. Do as the question asks.
[edit] Explanation
Bruteforce should be good enough. One shortcut to note is that n - (p * x) is maximized when p is 1.
5
4399
614
8201
101
7048
[edit] Output
2203
311
4111
53
3527