Problem2234-- Long Sequence

2234: Long Sequence

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

Description




Time Limit: 2 sec / Memory Limit: 1024 MB

Score : 300300 points

Problem Statement

We have a sequence of NN positive integers: A=(A_1,\dots,A_N)A=(A1,,AN).
Let BB be the concatenation of 10^{100}10100 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:
\displaystyle{\sum_{i=1}^{k} B_i \gt X}i=1kBi>X.

Constraints

  • 1 \leq N \leq 10^51N105
  • 1 \leq A_i \leq 10^91Ai109
  • 1 \leq X \leq 10^{18}1X1018
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:
NNA_1A1\ldotsA_NANXX

Output

Print the answer.

Sample Input Copy

3
3 5 2
26

Sample Output Copy

8

HINT

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

Source/Category