you game designer want obstacle course the player walk leave right you n height mountain select want arrange absolute difference height mountain small possible in addition want game difficult walk uphill flat hard walk downhill difficulty level number mountain 1 leq n h_i leq h_i1 h_i height ith mountain you do not want waste mountain model use from arrangement minimize h_1h_n find difficult if multiple order satisfy requirement find