Hyobin the Liar

Time limit2sMemory limit512 MB

Summary
Given missiles landing on distinct cells in order, find the first missile after which no legal placement of k non-touching ships of length a survives.
Level

Medium7 of 10

Topics
Binary search, Greedy, Prefix sum
Solved
No attempts yet

Problem

Yeongseon and Hyobin play a battleship game often. The board is a row of nn cells. One player attacks and the other defends.

The defender places kk ships on the board. One ship covers aa consecutive cells. Two ships may not overlap and may not touch, so at least one empty cell sits between neighbouring ships. The attacker cannot see where the ships are.

Once the ships are placed, the attacker fires mm missiles. One missile strikes one cell of the board, and the attacker wins as soon as a missile hits any ship.

This time Yeongseon attacks and Hyobin defends. Hyobin hates losing, so she decides to lie. Yeongseon cannot see the ships, so Hyobin claims a missile missed even when it hit. Hyobin still admits defeat at the moment no legal arrangement is left, that is, when every way of placing the kk ships is hit by at least one missile fired so far.

The missiles are fired in the given order. Find which missile makes Hyobin admit defeat.

Input

The first line contains the number of cells on the board nn, the number of ships kk, and the number of cells one ship covers aa. (1≤n,k,a≤2000001 \le n, k, a \le 200000)

The second line contains the number of missiles mm. (1≤m≤n1 \le m \le n)

The third line contains mm cell numbers, in firing order, where the missiles land. The cells of the board are numbered from 11 to nn from the left, and the mm numbers are distinct. With no missile fired yet, placing the kk ships under the rules is guaranteed to be possible.

Output

Print the position in the firing order of the missile at which Hyobin admits defeat. If an arrangement that dodges every missile remains, print −1-1.

Examples2

  1. Example 1

    Input
    11 3 3
    5
    4 8 6 1 11
    
    Expected output
    3
    
  2. Example 2

    Input
    5 1 3
    2
    1 5
    
    Expected output
    -1