'use strict'

function main(input) {
  input = input.split('\n').map(v => v.split(' ').map(v => ~~v))
  const n = input[0][0]
  const k = input[0][1]

  const nums = input[1].sort((a, b) => { return b - a}).slice(0, k)
  const ans = nums.reduce((a,b)=> a+b)

  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))