A relay squad lists n runners in a fixed lineup order, each with an integer skill rating. You must pick exactly k runners to form a team, keeping them in lineup order, so that their ratings are strictly increasing along the team. Among all valid teams, choose the one whose total rating is smallest, and report that total. If no strictly increasing team of exactly k runners exists, report -1.
Input format
Line 1: two integers n and k.
Line 2: n space-separated integers, the ratings in lineup order.
Output format
A single integer: the minimum total rating of a strictly increasing length-k subsequence, or -1 if impossible.
Constraints
- 1 <= n <= 1000
- 1 <= k <= n + 1
- -1000000 <= rating <= 1000000
- The answer fits in a signed 64-bit integer.