package main import ( "fmt" "sort" ) func main() { var n, k int fmt.Scan(&n, &k) a := make([]int, n) for i := range a { fmt.Scan(&a[i]) } sort.Ints(a) ans := 0 for i, v := range a { if v > 0 && n-i <= k { ans += v } } fmt.Println(ans) }