petya prepare birthday he decide n different dish dinner table number 1 n since Petya do not like cook want order dish restaurantsunfortunately dish prepare different restaurant Petya need pick order n different place to speed process want order courier delivery restaurant thus dish option Petya dish deliver courier restaurant case courier arrive a_i minute Petya go restaurant pick dish spend b_i minute each restaurant courier start deliver order moment Petya leave house in word courier work parallel Petya visit restaurant choose delivery consistentlyfor example Petya want order n 4 dish 3 7 4 5 b 2 1 2 4 order delivery fourth restaurant second then courier restaurant bring order 3 minute courier fourth restaurant bring order 5 minute Petya pick remain dish 1 2 3 minute thus 5 minute dish Petyas housefind minimum time dish Petyas home