Limits 2s, 512 MB

In order to pass time during your vacation, you decided to go on a hike to visit a scenic lake up in the mountains. Hiking to the lake will take you a full day, then you will stay there for a day to rest and enjoy the scenery, and then spend another day hiking home, for a total of three days. However, the accursed weather this summer is ridiculously warm and sunny, and since severe dehydration is not at the top of your priority list you want to schedule the three-day trip during some days where the two hiking days are the least warm. In particular you want to minimize the maximum temperature during the two hiking days.

Given the current forecast of daily maximum temperatures during your vacation, what are the best days for your trip?

Input

The first line of input contains an integer nn (3n503 ≤ n ≤ 50), the length of your vacation in days. Then follows a line containing n integers t1t_1, t2t_2, ..., tnt_n (20ti40-20 ≤ t_i ≤ 40), where tit_i is the temperature forecast for the ii-th day of your vacation.

Output

Output two integers dd and tt, where dd is the best day to start your trip, and tt is the resulting maximum temperature during the two hiking days. If there are many choices of dd that minimize the value of tt, then output the smallest such dd.

Samples

InputOutput
5
23 27 31 28 30
2 28
InputOutput
4
30 20 20 30
1 30

This NCPC 2019 problem is licensed under the CC BY-SA 3.0 license.

You can find the original problem on the NCPC website.

Submit

Login to submit.

Statistics

93% Solution Ratio
mdvirusEarliest, May '20
Tahmid690Fastest, 0.0s
Tahmid690Lightest, 131 kB
mdvirusShortest, 137B
Toph uses cookies. By continuing you agree to our Cookie Policy.