On the day of the competition, the laboratory uses computers. Unfortunately, the electricity is turned off, and the computers can only work on batteries. The technical staff of the competition has batteries. The -th battery allows any computer to work for a_i minutes.
Initially, there can be at most one battery per computer. After that, at any whole minute, you can remove the current battery from any computer and insert another one. The inserted battery can be either new or taken from another computer. You can assume that the process of removing and installing a battery takes no time. Note that batteries cannot be recharged.
The organizers want to determine the maximum number of minutes during which all computers can work simultaneously. It is quite difficult for the technical staff to determine this number. Help them.
The first line contains two integers and (1 \le n \le m \le 10^5) — the number of computers and batteries, respectively. The next line contains integers a_1, a_2, \dots, a_m (1 \le a_i \le 10^9) — the capacities of the batteries.
Output a single integer — the maximum number of minutes during which all computers can work simultaneously.
In this example, there are computers and batteries. Each battery has a capacity of minutes. Initially, we place the first and second batteries in the first and second computers, respectively. After minutes, remove the battery from the first computer and insert the third battery (still fully charged) into the first computer. At the end of the rd minute, the battery in the second computer will be depleted, so we remove it and insert the first battery that was taken from the first computer, which still has minute left. At the end of the th minute, this battery will also be depleted. Although the battery currently in the first computer has minute left, the other batteries are already used up, so we cannot keep both computers running any longer.
Example 1
Example 2
This problem consists of subtasks. Points for a subtask are awarded only if all the tests for that subtask are passed.
( points): a_i = 1;
( points): n = m;
( points): a_i \le 2;
( points): n = 2;
( points): no additional constraints;