package main import ( "fmt" "sort" ) func main() { var N, K int fmt.Scan(&N, &K) G := make([]int, N) for i := range G { fmt.Scan(&G[i]) } sort.Ints(G) total := 0 if G[N-1] >=0 { for i := (N - K); i < N ; i++ { if G[i] > 0 { total += G[i] } } }else{ total = G[N-1] } fmt.Println(total) }