eolymp
bolt
Try our new interface for solving problems
Problems

Subsequence

Subsequence

A sequence an of integers consists of n elements. For a given number k find a non-empty subsequence ai, ai+1, ... ai+m of consecutive elements of the sequence an, such that the sum of its elements as close as possible to k.

Input

The first line contains two integers n and k (1n500000, -109k109) - number of elements in the sequence and the desired sum. The second line is followed by n integers ai (-109ai109) - the elements of the sequence.

Output

Print one number |kl| (absolute difference of kl), where l is the total sum on optimum segment of the sequence.

Time limit 1 second
Memory limit 128 MiB
Input example #1
9 5
1 -2 2 -1 2 -1 3 -2 6
Output example #1
0
Author A. Milanin
Source ACM, Ukraine, First Stage, 09.04.2011