object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k: Int = sc.nextInt
  val monsters: Seq[Long] = Seq.fill(n)(sc.nextInt)
  val specialAttack: Int = Math.min(monsters.size, k)
  println(monsters.sorted.reverse.drop(specialAttack).sum)
}