let arr = readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
let n = arr[0]
var k = arr[1]

var i: Int = 0
var ret: Int = 0

var h = readLine()!.characters.split{$0==" "}.map{Int(String($0))!}
var sumH: Int = 0

h.forEach { sumH += $0 }

h = h.sort{$0>$1}

if( k >= h.count ) {
  k = h.count
}

var leng = h.count
if(k < (leng / 2)) {
  for i in 0..<k {
    sumH -= h[i]
  }
  ret = sumH
} else {
  for i in k..<leng {
    ret += h[i]
  }
}

print(ret)