"use strict"

let inputs = ``
let enemy =[]
let x = 0

const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
})

reader.on('line', function(input) {
  inputs += input+` `
})

reader.on('close', function() {
  let items = inputs.trim().split(' ')
  console.log(items);
  
  for(let i = 0 ; i < items.length ; i++){
    items[i] = parseInt(items[i])
    if(i>=2)enemy[i-2] = items[i]
  }

  enemy.sort(function(a,b){return (a < b ? 1 : -1)})
  
  for(let k = 0; k < enemy.length ; k ++){
    if(k < items[1]) {enemy[k] = 0}
    x += parseInt(enemy[k])
  }
  console.log(x);
})