polycarp practice problem solve skill he list n problem difficulty a_1 a_2 dot a_n respectively his plan practice exactly k day each day solve problem list Polycarp solve problem order give list skip problem list he solve n problem exactly k daysThus day Polycarp solve contiguous sequence consecutive problem start list he can not skip problem solve multiple time as result k day solve n problemsThe profit jth day Polycarps practice maximum difficulty problem Polycarp solve jth day ie solve problem indice l r day profit day maxlimits_l le le ra_i the total profit practice sum profit k day practiceyou want help Polycarp maximum possible total profit valid way solve problem your task distribute n problem k day satisfy condition way total profit maximumfor example n 8 k 3 5 4 2 6 5 1 9 2 possible distribution maximum total profit 5 4 2 6 5 1 9 2 here total profit equal 5 6 9 20