module.exports = function (N, staff, K) {
if (N === K){
return staff.reduce((accumulator, currentNumb) => accumulator += currentNumb, 0)
}
let maxNumbers = []
for (let i = 1; i <= K; i++){
let max = Math.max(...staff)
maxNumbers.push(max)
let indexOfMax = staff.indexOf(max)
staff.splice(indexOfMax, 1)
}
return maxNumbers.reduce((accumulator, currentValue) => accumulator += currentValue, 0)
}