Problem10253--CF EDU - Two Pointer Method - Step 3 - I. Segment with the Required Subset

10253: CF EDU - Two Pointer Method - Step 3 - I. Segment with the Required Subset

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 512 MiB

Description

Given an array of $n$ integers $a_i$. 
Let's say that a segment of this array $a[l..r]$ is good if on this segment it is possible to choose a certain set of numbers whose sum is equal to $s$. 
Your task is to find the shortest good segment.

Input

The first line contains integers $n, s\ (1≤n≤10^5,\ 1≤s≤1000)$. 
The second line contains numbers $a_i\ (1≤a_i≤s)$.

Output

Print one number, the minimum length of a good segment. If there is no good segment, print -1.

Sample 1 Input

10 100
14 33 22 21 11 5 13 28 61 2

Sample 1 Output

5

HINT

CF EDU.

Source/Category