A Scary Part-Time Job
InterviewTime limit1sMemory limit512 MB
Given daily wages, choose a contiguous range maximizing (length of range) times (minimum wage in that range).
Problem
Seonghwa owns a convenience store and pays wages in an unusual way.
- The amount of work changes from day to day, so the daily wage for each day is fixed in advance.
- Nobody is paid on the day worked. The whole sum is handed over when the worker quits.
- Seonghwa is greedy, so he settles up using the lowest daily wage inside the period worked. The payout is (number of days worked) times (the lowest daily wage in that period).
- To hide the fact that the daily wage changes, he never rehires anyone who has quit. Once you take the job you must show up every single day from your first day to your last.
Junsu needs to pay rent, so he wants to work at this store. A former employee explained the pay rule to him, and he has also learned the daily wage for each of the next days. Junsu picks one contiguous range of days between day 1 and day and works exactly that range. Working longer does not always pay more.
Find the largest payout Junsu can get.
Input
The first line contains the number of days available for work, ().
The second line contains the daily wages for day 1 through day , in order ().
Output
Print the largest payout Junsu can get on one line.