Trucks

Trucks cross a one-lane bridge in order under a weight limit; find the earliest time all have finished.

Easy3QueueSimulationInterviewNo attempts yetTime limit1sMemory limit512 MB

Problem

A single lane bridge crosses a river. nn trucks cross it in the given order. The order cannot be changed, and the trucks do not all weigh the same.

The bridge is ww units long, so at most ww trucks stand on it at the same time. Each truck moves exactly one unit of distance per unit of time. The total weight of the trucks that are on the bridge at any moment must be at most the maximum load LL. A truck that has not yet moved completely onto the bridge does not count toward that total.

Figure 1 shows four trucks with weights 7, 4, 5, 6 crossing from right to left when the bridge length ww is 2 and the maximum load LL is 10. The shortest time for all of them to cross is 8.

Figure 1. Trucks crossing the bridge.

Given the bridge length, the maximum load, and the weights of the trucks in crossing order, write a program that computes the shortest time for every truck to finish crossing.

Input

Input comes from standard input and has two lines.

The first line contains three integers nn, ww, and LL separated by spaces. nn is the number of trucks, ww is the length of the bridge, and LL is the maximum load of the bridge (1n10001 \le n \le 1000, 1w1001 \le w \le 100, 10L100010 \le L \le 1000).

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n separated by spaces. aia_i is the weight of the ii-th truck (1ai101 \le a_i \le 10).

Output

Print to standard output the shortest time for all trucks to cross the bridge, on one line.