~/algor $ cat problems/ochkoz-massivni-toldirish
Patching an array
Hard
1000 ms
128 MB
95%
$n$ positive integers in non-decreasing order and a positive integer $N$ are given. You may add some more positive integers to the array. The goal: every integer from $1$ to $N$ must be obtainable as a sum of some elements of the array (each element used at most once). What is the smallest number of numbers that must be added?
Input
The first line contains two positive integers: $n$ and $N$. The second line contains $n$ positive integers $a_{i}$ in non-decreasing order.
Output
One integer — the smallest number of numbers to add.
Note
$1 \le n \le 10^{5}$
$1 \le N \le 10^{18}$
$1 \le a_{1} \le a_{2} \le \dots \le a_{n} \le 10^{9}$
Examples
Input #1
3 20 1 5 10
Output #1
2
Input #2
2 3 1 2
Output #2
0