Олимпиадный тренинг

Задача 38277. Mom, I'm a dispatcher!


Maxim grew up, became disillusioned with big science and now works as an air traffic controller. Every day he does a very important and responsible thing: he lands planes.

This process is not as complicated as it might seem at first glance. The airport where Maxim works has only one runway, so planes must take turns landing. Landing takes b minutes. If the plane arrives and the runway is busy, it is sent to make additional circles over the city until it arrives at an airport with a free runway. One round takes f minutes. If the runway is clear, the plane will immediately start landing. If several planes approach an airport with a free runway at the same time, then one of them goes to land, while the others go to make additional circles.

Today, n planes should arrive at the airport, the time of arrival of each of them is known. How long will it take for all planes to land?

Input
The first line contains three integers n, b, f — the number of planes (1≤n≤1000), the time it takes to land and the time it takes to make one circle over the airport (1≤b, f≤109  ). The next line contains n integers ti — aircraft arrival times, listed in no particular order (0≤ti≤109 ).

Imprint
Print a single number: the time it takes for all planes to land.
 
Examples
# Input Output
1 10 5 12
13 0 1 10 20 20 2 1 10 20
79