#abc220c. [abc220_c]Long Sequence
[abc220_c]Long Sequence
Problem Statement
We have a sequence of positive integers: .
Let be the concatenation of copies of .
Consider summing up the terms of from left to right. When does the sum exceed for the first time?
In other words, find the minimum integer such that:
.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3
3 5 2
26
Sample Output 1
8
We have .
holds, but the condition is not satisfied when is or less, so the answer is .
Sample Input 2
4
12 34 56 78
1000
Sample Output 2
23