import Foundation
let rd = readLine()!.split(separator: " ").map({Int($0)!})
let a = readLine()!.split(separator: " ").map({Int($0)!}).sorted().reversed()
let start = a.startIndex
let end = a.index(a.startIndex, offsetBy: rd[1])
let sumArr = Array(a[start..<end])
print(sumArr.reduce(0,+))