jiahuimbzuai/CoQuIR huggingface dataset:
//  [rust]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn flatten_get(s: &mut [u32]) -> u32 {
    if s.len() == 0 {
        return 0;
    }
    let (index, min) =
        s.iter()
            .enumerate()
            .fold((0, std::u32::MAX), |(acc_index, acc), (index, v)| {
                if acc > *v {
                    (index, *v)
                } else {
                    (acc_index, acc)
                }
            });
    s.iter_mut().for_each(|v| *v -= min);
    let (left, right) = s.split_at_mut(index);
    let mut sum = min;
    sum += flatten_get(left);
    if right.len() > 0 {
        sum += flatten_get(&mut right[1..]);
    }
    sum
}

fn main() {
    input! {
        n: usize,
        hs: [u32; n],
    }

    let ans = flatten_get(&mut hs);
    println!("{}", ans);
}
//  [rust]
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<u32>();

    if v.len() == 1 {
        println!("{}", v[0]);
        return;
    }

    let mut count = 0;
    for i in 0..n {
        if i == 0 {
            if v[i] > 0 && v[i] >= v[i + 1] {
                count += v[i];
            }
        } else if i == n-1 {
            if v[i] > v[i-1] {
                count += v[i];
            }
        } else {
            if v[i] > v[i-1] && v[i] >= v[i+1] {
                count += v[i];
            } else if v[i] < v[i-1] && v[i] <= v[i+1] {
                count -= v[i];
            }
        }
    }
    println!("{}", count);
}
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
//    func enumerated() -> [(Int, Element)] {
//        return self.enumerate()
//    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var flowers = readIntSplit(by: " ")
var ans = 0
while flowers.max()! > 0 {
    var flag = false
    for i in 0..<N {
        if flowers[i] > 0 {
            flowers[i] -= 1
            if !flag {
                ans += 1
                flag = true
            }
        } else {
            flag = false
        }
    }
}
print(ans)
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var flowerH = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    var left = 0
    var right = 1
    var ans = 0
    while right <= flowerH.count && left < n{
        while right < n && flowerH[right - 1] <= flowerH[right] {
            right += 1
        }
        while left < n && flowerH[left] < 1 {
            left += 1
        }
        for i in left..<right {
            flowerH[i] -= 1
        }
        
        ans += left == right ? 0: 1
    }
    print(ans)
}
main()
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = firstIndex(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let n = readInt()
    var flowerH = readInts()
    //＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿ここまで入力
    
    var left = 0
    var right = 1
    var ans = 0
    while right <= flowerH.count && left < n{
        while right < n && flowerH[right - 1] <= flowerH[right] {
            right += 1
        }
        for i in left..<right {
            flowerH[i] -= 1
        }
        while left < n && flowerH[left] < 1 {
            left += 1
        }
        ans += 1
    }
    print(ans)
}
main()
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let n=tn(),ar=tnn(n),ans=ar[0]
  for(let i=1;i<n;i++){
    if(ar[i-1]<ar[i]){
      ans+=ar[i]-ar[i-1]
    }
  }
  to(ans)
}
main()
//  [typescript]
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const n = Number(stdin.split('\n')[0])
const h = stdin
  .split('\n')[1]
  .split(' ')
  .map(Number)

const ans = () => {
  let current = []

  for (let i = 0; i < n; i++) {
    current.push(0)
  }

  // 高さが足りないものを全てグループ化する
  // グループ化したものをすべて1増やす
  // 足りないものがなくなるまで繰り返す

  let count = 0
  while (1) {
    let head = -1
    let tail = -1

    // グループの始点と終点を探す
    for (let i = 0; i < n; i++) {
      if (head === -1 && current[i] < h[i]) {
        head = i
      }

      if (head > -1 && current[i] >= h[i]) {
        tail = i
        break
      }
    }

    // 終了条件
    if (head === -1) {
      return count
    }

    if (tail === -1) {
      tail = n
    }

    for (let i = head; i < tail; i++) {
      current[i] += 1
    }

    count++
  }
}

console.log(ans())
//  [typescript]
const solve = (input) => {
  const [n, hlist] = input.split("\n")
  const _hs = hlist.split(" ").map(Number)
  const hs = _hs.reduce((curr, next, i) => {
    if (_hs[i - 1] && _hs[i - 1] === _hs[i]) {
      return curr
    }
    return [...curr, next]
  }, [])
  let peaks = []
  hs.map((h, i, arr) => {
    const before = arr[i - 1] || 0
    const after = arr[i + 1] || 0
    // console.log(before, arr[i], after)
    if (arr[i] > before && arr[i] > after) {
      peaks.push(i)
    }
  })
  const pAndE = peaks.map((p) => {
    // let c = hs[p]
    for (i = p; i < hs.length; i++) {
      if (hs[i] < hs[i + 1]) {
        return {
          peak: p,
          peakValue: hs[p],
          edge: i,
          edgeValue: hs[i]
        }
      }
    }
    return {
      peak: p,
      peakValue: hs[p]
    }
  })
  let num = 0
  pAndE.map((p, j) => {
    num += p.peakValue
    if (j > 0) {
      const before = pAndE[j - 1]
      num -= before.edgeValue
    }
  })

  return num
}

if (process.env.NODE_ENV === "test") {
  module.exports = (input) => solve(input.trim())
} else {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(solve(input.trim()))
}
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);let input_i=-1;const tn=():number=>{input_i++;return Number(input[input_i])};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{input_i++;return String(input[input_i])};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{const t=[...ar];return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{const t=[...ar];return t.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1]}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const deduplicate=(a:any[]):any[]=>{return Array.from(new Set(a))};const gcd=(x,y)=>{while(y){[x,y]=[y,x%y]}return x};const sum=(arr)=>{return arr.reduce((a,b)=>a+b);};const isPrime=(n:number):boolean=>{if(n<2)return false;const suq=Math.sqrt(n);for(let i=2;i<=suq;i++){if(n%i==0){return false;}}return true;};
const main=()=>{
  let n=tn(),ar=tnn(n),start=-1,c=Infinity,flowers=new Array(n),ans=0
  flowers.fill(0)
  let e=0
  while(!e){
    e=1
    for(let i=0;i<n;i++){
      if(ar[i]==0||i==n-1){
        if(start!=-1){
          if(i==n-1){
            c=min(...ar.slice(start,i+1))
            for(let j=start;j<i+1;j++){
              ar[j]-=c
            }
          }else{
            c=min(...ar.slice(start,i))
            for(let j=start;j<i;j++){
              ar[j]-=c
            }
          }
          ans+=c
        }
        start=-1
        continue
      }
      if(start==-1){
        start=i
        e=0
      }
    }
  }
  to(ans+ar[ar.length-1])
}
main()
//  [typescript]
function main(input) {
  input = input.trim().split("\n");
  const n = Number(input[0]);
  const hs = input[1].split(" ").map(n => Number(n));
  const arr = Array(n).fill(0);
  let result = 0;
  const func = (l, r) => {
    if (l < 0 || n <= l || r < 0 || n <= r || r < l) return;
	const min = Math.min(...arr.slice(l, r+1);
    const target = Math.min(...hs.slice(l, r+1));
    const dif = target - min;
    const minIndices = [];
    for (let i = l; i <= r; i++) {
      arr[i] += dif;
      if (hs[i] === target) minIndices.push(i);
    }
    result += dif
    let nextL = l;
    for (let i = 0; i < minIndices.length; i++) {
      const index = minIndices[i];
      func(nextL, index-1);
      nextL = index + 1;
      if (i === minIndices.length -1) {
        func(nextL, hs.length -1);
      }
    }
  }
  func(0, n-1);
  console.log(result);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
function main(input: string): void {
  const s = Number(input);
  let n = s;
  // If a[i] === 4, then i+3 is the answer
  let step = 1;
  if (s === 1 || s === 2 || s === 4) {
    step = 0;
  }
  let fourHasAppeared = false;
  while (!fourHasAppeared) {
    if (n % 2) {
      n = n * 3 + 1;
    } else {
      n /= 2;
    }

    if (n === 4) {
      fourHasAppeared = true;
    }
    step += 1;
  }
  const ans = step + 3;
  console.log(ans);
}

import * as fs from 'fs';
main(fs.readFileSync('/dev/stdin', 'utf8'));
//  [python]

def main():
    n, k = map(int, input().split(" "))
    h = list(map(int, input().split(" ")))
    h.sort(reverse = True)
    print(sum(h[k:]))
    

if __name__ == "__main__":
    main()
//  [python]
import sys
input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    assert N == len(H)
    H.sort(reverse=True)
    print(sum(H[K:]))


if __name__ == '__main__':
    main()
//  [python]
n, k = map(int,input().split())
h = list(map(int,input().split()))

h.sort(reverse = True)
t = 0

del h[0:k]
    
if len(h) == 0 :
    print(0)
else:
    t += sum(h)
    print(t)
//  [python]
h,k = map(int,input().split())
lst = list(map(int,input().split()))
lst.sort()
print(sum(lst[:len(lst)-k]))
//  [python]
nn, kk = list(map(int,input().split()))
hh = list(map(int,input().split()))
hh.sort()
print(sum(hh[0:nn-kk]))
//  [python]
nn, kk = list(map(int,input().split()))
hh = list(map(int,input().split()))

print(nn,kk,hh)

hh.sort()
print(hh[0:nn-1])
print(sum(hh[0:nn-kk]))
//  [java]

import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0; i<N; i++) a[i] = sc.nextInt();
        Arrays.sort(a);
        if(N-K<=0){
            p(0);
            return;
        }
        long sum = 0;
        for(int i = N-1-K; i>=0; i--) {
            sum += a[i];
        }
        p(sum);
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}
//  [java]
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		int n = input.nextInt();
		int k = input.nextInt();
		int[] h = new int[n];
		int s = 0;
		for (int i = 0; i < n; i++) {
			h[i] = input.nextInt();
		}
		if (k >= n) {
			System.out.println(0);
		}else {
			Arrays.sort(h);
			for(int i = 0; i < n-k ;i++) {
				s += h[i]; 
			}
			System.out.printf("%d",s);
		}
		
	}
}
//  [java]
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int N = one.get(0);
		int K = one.get(1);
		long output = 0;
		ArrayList<Integer> list = nextIntArray();
		Collections.sort(list, Comparator.reverseOrder());
		for(int i = K; i < H; i++){
			output += list.get(i);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}
//  [java]
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		int H = one.get(0);
		int K = one.get(1);
		long output = 0;
		ArrayList<Integer> list = nextIntArray();
		Collections.sort(list, Comparator.reverseOrder());
		for(int i = K; i < N; i++){
			output += list.get(i);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}
//  [cpp]
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), K = getint();
	int H[200000];
	rep(i, N) H[i] = getint();
	pakuri_sort(N, H);

	int kaisuu = max(0, N - K);

	ll kotae = 0;
	rep(i, kaisuu) kotae += H[i];

	printf("%lld", kotae);

	Would you please return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

ll n,m,a[1 << 18],suma;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	cin >> n >> m;
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	for(int i=0; i<n-m; i++){
		suma+=a[i];
	}
	cout << suma << endl;
	return 0;
} 
//^-^
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,k; cin>>n>>k;
  vector<long long> h(n);
  for(auto& i:h) cin>>i;
  sort(h.begin(),h.end());
  long long res=0;
  for(auto& i:(n-k)) res+=i;
  cout<<res;
  return 0;
}
//  [cpp]
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)
 
 
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    vector<ll> H(n,0);
    rep(i,n){
        cin >> H[i];
    }
    sort(H.begin(),H.end());

    for(int i=0;i<n-k;i++){
        ans+=H[i];
    }
    cout << ans + k << endl;
    return 0;
}
//  [c]
// ABC 153-C
// 2020.1.26 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef long long ll;

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

#define INCmode   1  // 昇順ソート
typedef int Int;
void Usort(Int *a, int n) {
	int i, k;
#define B 8
#define BMSK 255 // (1<<8)-1
	Int t1[1 << B], t2[1 << B];
	
	Int *tmp = malloc(n * sizeof(Int));	
	for (k = 0; k < 4; ++k) {  // for 32ビット
		memset(t1, 0, sizeof(t1)), memset(t2, 0, sizeof(t2));
		for (i = 0; i < n; ++i)	t1[(a[i] >> k*B) & BMSK]++;
#if INCmode
		for (i = 0; i < BMSK; ++i) t1[i+1] += t1[i];
#else
		i = BMSK+1; while (--i) t1[i-1] += t1[i];
#endif
		i = n; while (i--) tmp[--t1[(a[i] >> k*B) & BMSK]] = a[i];
		k++;
		for (i = 0; i < n; ++i) t2[(tmp[i] >> k*B) & BMSK]++;
#if INCmode
		for (i = 0; i < BMSK; ++i) t2[i+1] += t2[i];
#else
		i = BMSK+1; while (--i) t2[i-1] += t2[i];
#endif
		i = n; while (i--) a[--t2[(tmp[i] >> k*B) & BMSK]] = tmp[i];
	}
	free(tmp);
//  for (i = 0; i < n; ++i) printf("[%d] %lld\n", i, a[i]);
}


int N;
int H[200005];

int main()
{
	int i, K, N;
	ll s;
	
	N = in(), K = in();
	for (i = 0; i < N; ++i) H[i] = in();
	Usort(H, N);
	s = 0, N -= K;
	for (i = 0; i < N; ++i) s += H[i];
	printf("%lld\n", s);
	return 0;
}
//  [c]
// ABC 153-C
// 2020.1.26 bal4u

#include <stdio.h>

typedef long long ll;

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0; int c;
	c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void Qsort(int *a, int l, int r) {
	int i, j, m; int t;
	
	i = l, j = r, m = a[(l+r) >> 1];
	while (1) {
#if 1  // 昇順
		while (a[i] < m) i++;
		while (m < a[j]) j--;
#else  // 降順
		while (a[i] > m) i++;
		while (m > a[j]) j--;
#endif
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

int N;
int H[200005];

int main()
{
	int i, K, N;
	ll s;
	
	N = in(), K = in();
	for (i = 0; i < N; ++i) H[i] = in();
	Qsort(H, 0, N-1);
	s = 0, N -= K;
	for (i = 0; i < N; ++i) s += H[i];
	printf("%lld\n", s);
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int asc(const void *a, const void *b) {
	return *(int *)b - *(int *)a;
}

int main(void) {
	int N;//num of monster
	int *H;//hit point of monsters
	int K;//special attak
	int i;
	unsigned long long int sum;
	char buf[128], *ch;
	char *buf_array;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	N = atoi(ch);
	ch = strtok(NULL, " ");
	K = atoi(ch);

	buf_array = (char *)calloc(N * 12, sizeof(char));
	H = (int *)calloc(N, sizeof(int));

	fgets(buf_array, N * 12, stdin);
	ch = strtok(buf_array, " ");
	H[0] = atoi(ch);
	for(i = 1; i < N; i += 1) {
		ch = strtok(NULL, " ");
		H[i] = atoi(ch);
	}
	free(buf_array);

	qsort(H, N, sizeof(int), asc);
	sum = 0;
	for(i = K; i < N; i += 1) {
		sum += (unsigned long long int)H[i];
	}
	printf("%llu\n", sum);

	free(H);
	return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
int asc(const void *a, const void *b);

int main(void)
{
    int n=0,k=0;
    long int count=0;
    long int H[200000]={};
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++) scanf("%ld",&H[i]);
    qsort(H,n,sizeof(long int),asc);
    for(int i=0;i<=n-k;i++) count+=H[i];
    printf("%ld",count);
    return 0;
}

int asc(const void *a, const void *b){
    long *A = (long *)a;
    long *B = (long *)b;
    if (*A > *B) return 1;
    if (*A < *B) return -1;
    return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

void sort(int *a, int n);

void sort(int *a, int n){
	int i, j, max, index;

	for(i=0; i<n-1; i++){
		max = *(a+i);	index = i;
		for(j=i+1; j<n; j++){
			if(max < a[j]){
				max = a[j];	index = j;
			}
		}
		a[index] = a[i];	a[i] = max;
	}
}
int main(void){
	int i, n, k;
	long x=0;

	scanf("%d%d", &n, &k);
	int *p = (int *)malloc(sizeof(int)*n);
	for(i=0; i<n; i++){
		scanf("%d",p+i);
	}
	sort(p, n);

	for(i=k; i<n; i++){
		x += *(p+i);
	}
	free(p);
	printf("%ld\n", x);
	return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>

void sort(int *a, int n);

void sort(int *a, int n){
	int i, j, max, index;

	for(i=0; i<n-1; i++){
		max = *(a+i);	index = i;
		for(j=i+1; j<n; j++){
			if(max < a[j]){
				max = a[j];	index = j;
			}
		}
		a[index] = a[i];	a[i] = max;
	}
}
int main(void){
	int i, n, k;
	long x=0;

	scanf("%d%d", &n, &k);
	int *p = (int *)malloc(sizeof(int)*n);
	for(i=0; i<n; i++){
		scanf("%d",p+i);
	}
	sort(p, n);

	for(i=k; i<n; i++){
		x += *(p+i);
	}
	printf("%ld\n", x);
	return 0;
}
//  [javascript]
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    nk = input[0].split(" ");
    hhh = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var n = parseInt(nk[0], 10);
    var k = parseInt(nk[1], 10);
    var total=0;
    if (n<=k){console.log(total);
             }
    else{
    var H =[];total=0;
    for (i=0;i<n;i++){
        var h = parseInt(hhh[i], 10);
        total +=h;
        H[i]=h;
    }
  //  console.log(H);
    H.sort((a,b) => b-a);
  //  console.log(H);
    var ktotal=0;
    for(i=0;i<k;i++){ktotal+=H[i];}
   // console.log(total,ktotal);
    console.log(total-ktotal);
 }

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main(input) {

    var input = input.split("\n");

    const N = Number(input[0].split(" ")[0]);
    const K = Number(input[0].split(" ")[1]);
    const H = input[1].split(" ").map(Number);

    // 必殺技(K回) > モンスター(N体) は即抜け
    if (K >= N) {
        //出力
        console.log(0);
        return;
    }

    const sortDesc = H.sort(function (a, b) {
        return b - a;
    });

    var answer = 0;
    for (var i = K; i < N; i++) {
        answer += sortDesc[i];
    }

    //出力
    console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict"
function Main(input) {

    var input = input.split("\n");

    const N = Number(input[0].split(" ")[0]);
    const K = Number(input[0].split(" ")[1]);
    const H = input[1].split(" ").map(Number);

    // 必殺技(K回) > モンスター(N体) は即抜け
    if (K >= N) {
        //出力
        console.log(0);
        return;
    }

    const sortDesc = H.sort(function (a, b) {
        return b - a;
    });

    let answer = 0;
    for (let i = K; i < N; i++) {
        answer += sortDesc[i];
    }

    //出力
    console.log(answer);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
function Main (input) {
  input = input.split("\n").map(inp => inp.split(" ").map(Number));
  var N = input[0][0];
  var K = input[0][1];
  var H = input[1];
  var ans = 0;
  H.sort((a, b) => b > a);
  for (var i = 0; i < K; i++) {
    if (i+1 > N) {
      break;
    }
    else {
      H.shift();
    }
  }
  for (var i of H) {
    ans += i;
  }
  console.log(ans);
}
  
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
process.stdin.resume();
process.stdin.setEncoding("utf8");
var lines = [];
var reader = require("readline").createInterface({
	input: process.stdin,
	output: process.stdout
});
reader.on("line", (line) => {
	lines.push(line);
});
reader.on("close", () => {
	var e = lines[0].split(" "), n = Number(e[0]), k = Number(e[1]);
	var f = lines[1].split(" "), s = [];
	for(var i=0; i<n;i++){
		s.push(Number(f[i]));
	}

	//配列の最大値を取得して削除 k回行う
	for(var x=0;x<k;x++){
		var max_value = Math.max.apply(null, s);
		var max_index = s.indexOf(max_value);
		s.splice(max_index, 1);
		if(s.length === 0) {
			s.push(0);
			break;
		}
	}

	var sum = s.reduce((a, b) =>a + b);
	console.log(sum);

});
//  [go]
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
	"strings"
)

func solution(n, k int, h []int) int {
	if n <= k {
		return 0
	}
	sort.Ints(h)
	return sliceSum(h[:n-k])
}

func sliceSum(s []int) int {
	var sum int
	for _, v := range s {
		sum += v
	}
	return sum
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10240*10240)

	var n, k int
	var err error
	fmt.Scan(&n, &k)
	h := make([]int, n)
	ss := strings.Split(readLine(reader), " ")
	for i := range ss {
		h[i], err = strconv.Atoi(ss[i])
		checkError(err)
	}
	fmt.Println(solution(n, k, h))
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}
//  [go]
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	for i := range h {
		fmt.Scan(&h[i])
	}

	sort.SliceStable(h, func(i, j int) bool { return h[i] < h[j] })

	d := n - k
	if d < 1 {
		d = 0
	}
	ans := 0
	for _, i := range h[:d] {
		ans += i
	}
	fmt.Println(ans)
}
//  [ruby]
line = gets.split(' ')

monster_count = line[0].to_i
skill_count = line[1].to_i

monsters = gets.split.map(&:to_i)

if monster_count <= skill_count
  puts 0
else
  monsters.sort!.reverse!

  monsters.slice!(0..(skill_count - 1)) if skill_count != 0
  count = 0
  monsters.each {|monster| count += monster }

  puts count
end
//  [ruby]
h,n = gets.split.map(&:to_i)  # スペースで区切られた複数の整数
ary = gets.split.map(&:to_i)  # スペースで区切られた複数の整数

#newary = ary.sort {|a, b| (-1) * (a <=> b) }  # 配列降順ソート
ary.sort! #配列昇順ソート

i = 0

#必殺技判定
if n >= h then
  puts i
  exit
else
  h = h - n #必殺技分だけ減算
end

ans = 0

while i < h do
  ans = ans + ary[i]
  i = i + 1
end

puts ans
//  [ruby]
N, K = gets.split.map(&:to_i)
H = gets.split.map(&:to_i).sort.reverse

if H.size <= K
  puts 0
  exit
end

result = 0
H[K..-1].each do |hp|
  result += hp
end

puts result
//  [ruby]
_,k,*h=`dd`.split.map(&:to_i)
k.times{h.pop}
p h.sum
//  [ruby]
N,K = gets.strip.split.map(&:to_i)
num = gets.strip.split.map(&:to_i)
ary = num.sort
if N-K-1 >= 0 then
  puts ary[0..(N-K-1)].sum
else
  puts 
end
//  [ruby]
N,K = gets.strip.split.map(&:to_i)
num = gets.strip.split.map(&:to_i)
ary = num.sort
puts ary[0..(N-K-1)].sum
//  [rust]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let k:usize = read();
    let v:Vec<u128> = (0..n).map(|_| read()).collect();
    if k >= n {
        println!("0");
    } else {
        let v = &v[0..n-k];
        println!("{}", v.iter().sum::<u128>());
    }
}
//  [rust]
use std::cmp::Reverse;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        k: usize,
        h: [usize;n],
    }

    let mut h_tmp: Vec<usize> = Vec::with_capacity(n);
    for value in h {
        h_tmp.push(value);
    }

    h_tmp.sort_by_key(|&x| Reverse(x));
    
    let mut ans = 0;
    for i in 0..n {
        if i+1 > k {
            ans += h_tmp[i];
        }
    }

    println!("{}", ans);

}
//  [swift]
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}



func main() {
    let nk = readInts()
    let (n, k) = (nk[0], nk[1])
    var aryA = readInts()
    //__________________________ここまで入力
    aryA.sort()
    
    if k <= n {
        aryA.removeLast(k)
    } else {
        aryA.removeAll()
    }
    
    print(aryA.reduce(0) { $0 + $1 })
}

main()
//  [swift]
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let K = input[1]
let H = readLine()!.split(separator: " ").map { Int($0)! }.sorted()

var sum = 0
var i = 0
while i < H.count - K {
  sum += H[i]
  i += 1
}
print(sum)
//  [swift]
extension String:CollectionType{}
func readInts()->[Int]{
  return readLine()!.split(" ").map{Int($0)!}
}
var a:[Int]=readInts()
var n=a[0]
var k=a[1]
var h:[Int]=readInts()
var sh=h.sort{$0<$1}
var sum:Int64=0
if(n<=k){print(0)}
else{
  for i in 0..<n-k{
  sum=sum+sh[i]
}
print(sum)
}
//  [swift]
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;


int main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
  
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end(), std::greater<long long>());
  
  	long long ret = 0;
 	for(int i = K; i<N; i++) {
		ret += H[i];
    }
  
  	cout << ret << endl;
}
//  [swift]
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)
//  [typescript]
import * as fs from 'fs';
 
const lines = fs.readFileSync('/dev/stdin', 'utf8').split("\n");
let [n,k] = lines[0].split(" ").map(Number);
let h = lines[1].split(" ").map(Number);
h.sort((a, b)=>b-a);
let ans = 0;
for(let i = k; i < n; i++){
    ans += h[i];
}
console.log(ans);
//  [typescript]
"use strict";

const fs = require("fs");

const main = (argv: string[]) => {
  const [N, K] = argv[0].split(" ").map(Number);
  if (N <= K) {
    console.log(0);
    return;
  }
  const hps = argv[1].split(" ").map(Number);
  const sorted = hps.sort((a, b) => b - a);
  console.log(sorted.slice(K).reduce((a, c) => a + c));
}

const parser = (argv: any) => {
  main(argv.split("\n"));
}

parser(fs.readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
{
  const main = (
    input: string
  ): void | string | number | string[] | number[] => {
    const r = _reader(input)
    const [N, K] = r.nn()
    const A = r.nn()

    A.sort((a, b) => b - a)

    let sum = 0

    for (let i = K; i < N; i++) {
      sum += A[i]
    }

    return sum
  }

  const _reader = (str: string, i = 0) => {
    const lines = str.trim().split('\n')
    const s = () => lines[i++] || ''
    const n = () => Number(s())

    const mn = (v: string[]) => v.map(Number)
    const sp = (v: string) => v.split(' ')
    const ss = () => sp(s())
    const nn = () => mn(ss())
    const nls = () => mn(lines.slice(i))
    const nnls = () => lines.slice(i).map(v => mn(sp(v)))

    return { lines, s, n, ss, nn, nls, nnls }
  }

  const _getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const _res = main(_getInput())

  if (typeof _res === 'number' || typeof _res === 'string') console.log(_res)
  if (typeof _res === 'object') console.log(_res.join(' '))
}