#CCBOTPBA0000051. Lần đầu vượt ngân sách (First Budget Exceedance)

Lần đầu vượt ngân sách (First Budget Exceedance)

First Budget Exceedance

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

A person has a budget of BB and records nn expenses in chronological order. The ii-th expense costs aia_i. The cumulative cost after expense ii is Si=a1+a2+⋯+aiS_i=a_1+a_2+\cdots+a_i. Find the first 1-based position ii such that Si>BS_i>B. If no expense makes the cumulative cost exceed the budget, print −1-1. When n=0n=0, there are no expenses.

Input

The first line contains two integers nn and BB: the number of expenses and the budget. If n>0n>0, the following input contains nn non-negative integers a1,a2,…,ana_1,a_2,\ldots,a_n in chronological order, separated by whitespace and possibly spread across multiple lines. If n=0n=0, no aia_i follows.

Output

Print one integer: the smallest position ii with Si>BS_i>B, or −1-1 if none exists.

Subtasks

  • Subtask 1 (20%): 0≤n≤20, 0≤B≤109, 0≤ai≤1090\le n\le20,\ 0\le B\le10^9,\ 0\le a_i\le10^9.
  • Subtask 2 (30%): 0≤n≤1000, 0≤B≤109, 0≤ai≤1090\le n\le1000,\ 0\le B\le10^9,\ 0\le a_i\le10^9.
  • Subtask 3 (50%): 0≤n≤105, 0≤B≤109, 0≤ai≤1090\le n\le10^5,\ 0\le B\le10^9,\ 0\le a_i\le10^9.

Examples

Example 1

Input:

4 10
3 2 6 1

Output:

3

Explanation: The first three cumulative costs are 33, 55, and 1111. Since 11>1011>10 and the earlier totals are not above 1010, the first position is 33.

Example 2

Input:

3 10
4 6 0

Output:

-1

Explanation: The cumulative costs are 44, 1010, and 1010. Equality with the budget is not an exceedance. No valid position exists.

Example 3

Input:

0 0

Output:

-1

Explanation: There are no expenses, so no position can exceed the budget.