#jag2017summerday3b. [jag2017summer_day3_b]Slimming Plan

[jag2017summer_day3_b]Slimming Plan

MathJax.Hub.Config({ tex2jax: { inlineMath: [["","",""], ["\\(","\\)"]], processEscapes: true }}); blockquote { font-family: Menlo, Monaco, "Courier New", monospace; color: #333333; display: block; padding: 8.5px; margin: 0 0 9px; font-size: 16px; line-height: 18px; background-color: #f5f5f5; border: 1px solid #ccc; border: 1px solid rgba(0, 0, 0, 0.15); -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; white-space: pre; white-space: pre-wrap; word-break: break-all; word-wrap: break-word; }

Problem Statement

Chokudai loves eating so much. However, his doctor Akensho told him that he was overweight, so he finally decided to lose his weight.

Chokudai made a slimming plan of a DD-day cycle. It is represented by DD integers w_0,ldots,w_D1w\_0, \\ldots, w\_{D-1}. His weight is SS on the 00-th day of the plan and he aims to reduce it to T(S>T)T \\ (S > T). If his weight on the ii-th day of the plan is xx, it will be x + w\_{i \\% D} on the (i+1)(i+1)-th day. Note that ii \\% D is the remainder obtained by dividing ii by DD. If his weight successfully gets less than or equal to TT, he will stop slimming immediately.

If his slimming plan takes too many days or even does not end forever, he should reconsider it.

Determine whether it ends or not, and report how many days it takes if it ends.


Input

The input consists of a single test case formatted as follows.

STDS \\ T \\ D w_0cdotsw_D1w\_0 \\cdots w\_{D-1}

The first line consists of three integers S,T,D(1leS,T,Dle100,000,S>T)S, T, D \\ (1 \\le S,T,D \\le 100{,}000, \\ S > T). The second line consists of DD integers w_0,ldots,w_D1w\_0, \\ldots, w\_{D-1} (100,000lew_ile100,000-100{,}000 \\le w\_i \\le 100{,}000 for each ii).

Output

If Chokudai's slimming plan ends on the dd-th day, print dd in one line. If it never ends, print 1-1.


Sample Input 1

65 60 3
-2 3 -4

Output for Sample Input 1

4

Chokudai's weight will change as follows: 65to63to66to62to6065 \\to 63 \\to 66 \\to 62 \\to 60.


Sample Input 2

65 60 3
-2 10 -3

Output for Sample Input 2

-1

Chokudai's weight will change as follows: $65 \\to 63 \\to 73 \\to 70 \\to 68 \\to 78 \\to 75 \\to \\cdots$.


Sample Input 3

100000 1 1
-1

Output for Sample Input 3

99999

Sample Input 4

60 59 1
-123

Output for Sample Input 4

1