#include <iostream>
using namespace std;

int main() {
	long K,T;
	cin >> K >> T;
	
	long a,max=0;
	
for(long i=0; i<T; i++){
	cin >> a;
	if(a>max){max=a;}
}

long kazu=2*max - K -1;
if(kazu>0){cout << kazu << endl;}
else{cout << 0 << endl;}
	return 0;
}
### Prompt

Please formulate a CPP solution to the following problem:

There are K pieces of cakes. Mr. Takahashi would like to eat one cake per day, taking K days to eat them all.

There are T types of cake, and the number of the cakes of type i (1 ≤ i ≤ T) is a_i.

Eating the same type of cake two days in a row would be no fun, so Mr. Takahashi would like to decide the order for eating cakes that minimizes the number of days on which he has to eat the same type of cake as the day before.

Compute the minimum number of days on which the same type of cake as the previous day will be eaten.

Constraints

* 1 ≤ K ≤ 10000
* 1 ≤ T ≤ 100
* 1 ≤ a_i ≤ 100
* a_1 + a_2 + ... + a_T = K

Input

The input is given from Standard Input in the following format:


K T
a_1 a_2 ... a_T


Output

Print the minimum number of days on which the same type of cake as the previous day will be eaten.

Examples

Input

7 3
3 2 2


Output

0


Input

6 3
1 4 1


Output

1


Input

100 1
100


Output

99

### Response

```cpp
#include <iostream>
using namespace std;

int main() {
	long K,T;
	cin >> K >> T;
	
	long a,max=0;
	
for(long i=0; i<T; i++){
	cin >> a;
	if(a>max){max=a;}
}

long kazu=2*max - K -1;
if(kazu>0){cout << kazu << endl;}
else{cout << 0 << endl;}
	return 0;
}
```