Vova moved from Guangzhou to Shenzhen. He immediately found out that the
local people don't understand his Cantonese phrases as well. Vova tried
chatting with them in Mandarin, but to no success.
Then Vova decided to learn more about Chinese dialects. It turned out that
people in China speak k different dialects, at that at least a1
people speak the first dialect, at least a2 people speak the second
dialect, …, at least ak people speak the k-th dialect.
How many people speak all k dialects if the population of China is n
people?
Input
The first line contains integers n and k (2 ≤ k ≤ 20;
1 ≤ n ≤ 109). The second line contains space-separated integers
a1, …, ak (1 ≤ ak ≤ n).
Output
Print the minimum number of people in China that speak all k dialects of
the Chinese language.
Samples
input | output |
---|
1000000000 2
800000000 800000000
| 600000000
|
1000000000 2
500000000 500000000
| 0
|
Problem Author: Alexander Ipatov
Problem Source: Open Ural FU Personal Contest 2013