Jaeui signed up for a strange contest called King of penalty. It works like ICPC, with these rules.
The moment the contest starts, Jaeui reads all N problems and works out how many minutes each one costs him. His code is never wrong, and once he starts writing a solution he finishes it before he starts another one. Submitting takes 0 minutes. He picks when to start each problem and may wait and do nothing. He cannot submit after the contest is over, so a solution he finishes writing at minute P is never submitted.
Suppose P=30, N=3, and the three problems cost 2, 12, and 16 minutes. If he writes them from the start in the order 2, 12, 16, the first problem gets penalty 2 and the second gets penalty 14, while the last one is finished at exactly minute 30 and cannot be submitted. He solves two problems for a penalty of 16. That is the largest number of problems, but not the largest penalty. To collect the most penalty he waits until minute 15, then solves the 12 minute problem and the 2 minute problem in that order. The penalty is 27 plus 29, which is 56, and no schedule does better.
Find the largest number of problems Jaeui can solve, and the largest penalty he can collect while solving that many.
The first line contains the contest length P (1≤P≤109) and the number of problems N (1≤N≤100000), separated by a space.
The second line contains N integers separated by spaces. The i-th integer is the number of minutes Jaeui spends writing problem i, and it is at least 0 and less than P.
Print the largest number of problems Jaeui can solve within the contest, and the largest penalty he can collect while solving that many, on one line separated by a space.