100 atcoder#ABC220C. [ABC220C] Long Sequence

[ABC220C] Long Sequence

Score : 300300 points

Problem Statement

We have a sequence of NN positive integers: A=(A1,,AN)A=(A_1,\dots,A_N). Let BB be the concatenation of 1010010^{100} copies of AA.

Consider summing up the terms of BB from left to right. When does the sum exceed XX for the first time? In other words, find the minimum integer kk such that:

i=1kBi>X\displaystyle{\sum_{i=1}^{k} B_i \gt X}.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • 1X10181 \leq X \leq 10^{18}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 \ldots ANA_N

XX

Output

Print the answer.

3
3 5 2
26
8

We have B=(3,5,2,3,5,2,3,5,2,)B=(3,5,2,3,5,2,3,5,2,\dots). i=18Bi=28>26\displaystyle{\sum_{i=1}^{8} B_i = 28 \gt 26} holds, but the condition is not satisfied when kk is 77 or less, so the answer is 88.

4
12 34 56 78
1000
23