func main() var n: int :: cui@inputInt() var k: int :: cui@inputInt() var a: []int :: #[n]int for i(0, n - 1) do a[i] :: cui@inputInt() end for do a.sort() var b: []int :: #[n - 1]int for i(0, n - 2) do b[i] :: a[i + 1] - a[i] end for do b.sort() var ans: int :: a[n - 1] - a[0] for i(1, k - 1) do ans :- b[n - 1 - i] end for do cui@print("\{ans}\n") end func