Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/ikki-korsatkich-eng-qisqa-qism

Segment with sum at least s

Medium 1000 ms 128 MB 60%
Share

A positive integer $n$, an array $a$ of $n$ positive integers and a positive integer $s$ are given. Find the length of the shortest segment of consecutive elements whose sum is at least $s$. If there is no such segment, print $-1$.

The shortest contiguous segment of the array with sum at least s

Input

The first line contains two positive integers: $n$ and $s$. The second line contains $n$ positive integers $a_{i}$ separated by spaces.

Output

One integer — the length of the shortest segment, or $-1$.

Note

$1 \le n \le 10^{5}$
$1 \le a_{i} \le 10^{4}$
$1 \le s \le 10^{9}$

Examples

Input #1
6 7
2 3 1 2 4 3
Output #1
2
Input #2
3 11
1 2 3
Output #2
-1

Sign in to submit a solution

Signing up is free and takes a minute.