Problem C
Bus Ticket
Dang it! Your period ticket for the local Bus-Go-On-system (BGO) has expired. At first you wanted to buy a new period already today, but you suddenly realize that your next ticket would then expire a few days before your vacation starts, leaving a few trips you need to pay for individually anyways. Perhaps it is cheaper to pay for an individual trip now, allowing the next period ticket to cover more trips of the future?
Input
The first line of input contains four positive integers
On the second line follows
Output
The smallest possible cost of making the trips.
Sample Input 1 | Sample Output 1 |
---|---|
10 25 30 6 0 1 2 30 30 32 |
45 |