Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/ochkoz-yoqilgi-quyish

Gas stations

Medium 1000 ms 128 MB 60%
Share

A car drives along a straight road from point $0$ to point $D$. With a full tank it covers $L$ km; it starts the trip with a full tank. There are $n$ gas stations along the road, the $i$-th at point $x_{i}$; at a station the tank is always filled up completely. What is the smallest number of refuelings needed to reach $D$? If $D$ cannot be reached, print $-1$.

Stations on the road axis; the full-tank range and the chosen stops

Input

The first line contains three positive integers: $D$, $L$ and $n$. The second line contains $n$ positive integers $x_{i}$ in increasing order.

Output

One integer — the smallest number of refuelings or $-1$.

Note

$1 \le n \le 10^{5}$
$1 \le L, D \le 10^{9}$
$0 \lt x_{1} \lt x_{2} \lt \dots \lt x_{n} \lt D$

Examples

Input #1
950 400 4
200 375 550 750
Output #1
2
Input #2
10 3 2
1 2
Output #2
-1

Sign in to submit a solution

Signing up is free and takes a minute.