Time limit
2s
Memory limit
128 MB
Kyungrae raises chickens, and this winter he has produced many eggs. He wants to sell them on an online marketplace.
Kyungrae has N eggs and M potential customers. Customer i says they are willing to buy one egg for at most P_i.
Kyungrae will not sell more than one egg to the same customer. If he chooses one selling price A, every customer with P_i at least A buys one egg. However, he cannot sell more than the N eggs he has.
Choose a selling price that maximizes Kyungrae's revenue. If multiple prices give the maximum revenue, output the lowest such price.
The first line contains two integers N (1 ≤ N ≤ 1,000) and M (1 ≤ M ≤ 1,000).
Each of the next M lines contains one integer P_i (1 ≤ P_i ≤ 1,000,000), the maximum price customer i is willing to pay for one egg.
Print two integers separated by a space: the lowest selling price that gives the maximum revenue, and the maximum revenue obtainable at that price.