Paul the barista has N coffee beans laid out in a row. He picks some of them and brews them. The picked beans keep the order they were laid out in.
Each bean carries one integer that names its kind. Write the kinds of the picked beans in order as a sequence A. The extraction has good quality when at least one of the two conditions below holds for every i with i≥2.
Ai−1≡Ai(modk)
Ai−1−d≤Ai≤Ai−1+d
Find the largest number of beans Paul can pick while the quality stays good.
Input
The first line contains N, k, and d, separated by spaces. (1≤N≤5×105, 1≤k,d≤5×105)
The second line contains a sequence S1,S2,…,SN of length N giving the kind of each bean in the order the beans are laid out. (1≤Si≤5×105)
Output
Print the largest number of beans in a good extraction.