Under construction

Still being built. Things may change

Raehwan's Mission to Get a Girlfriend

Interview

Time limit1sMemory limit1024 MB

Summary
Given daily weight losses A_i, find the latest start day s such that dieting every day from s through N loses at least M units, or -1 if no start day works.
Level

Easy3 of 10

Topics
Prefix sum, Two pointers
Solved
No attempts yet

Problem

Raehwan has a blind date NN days from now, and he wants to find a girlfriend. He decides to lose MM units of weight through a diet. Raehwan knows in advance the weight loss AiA_i from dieting on day ii (i=1,2,⋯ ,Ni = 1, 2, \cdots, N). Because he keeps a regular routine, his weight does not change on days when he does not diet.

Find the latest day on which he can start his diet and still reach his goal before the blind date.

Input

The first line contains two integers NN (1≤N≤1051 \le N \le 10^5) and MM (1≤M≤1091 \le M \le 10^9), separated by a space.

The second line contains NN integers A1,A2,⋯ ,ANA_1, A_2, \cdots, A_N, separated by spaces. (1≤Ai≤1041 \le A_i \le 10^4)

Output

Print the day number from which Raehwan should start his diet so that he postpones it as long as possible and still reaches his goal. If the diet can never succeed, print −1-1 instead.

Examples2

  1. Example 1

    Input
    4 7
    5 4 2 2
    
    Expected output
    2
    
  2. Example 2

    Input
    5 6
    1 1 1 1 1
    
    Expected output
    -1