import Foundation
func toTuple<T>(_ args: [T]) -> (T, T) { (args[0], args[1]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (_, k) = toTuple(readInts())
let li = readInts().sorted { $0 > $1 }
let ans = li[0..<k].reduce(0) { $0 + $1 }
print(ans)