stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include<algorithm>

#include<cmath>

using namespace std;



int main()

{

   unsigned long long n,k;

  unsigned long long arr[200005];

  unsigned long long maxm=1;

   unsigned long long cnt =0;



  cin>>n>>k;



  for(int i=0;i<n;i++){

        cin>>arr[i];

        cnt+=arr[i];

  }

  sort(arr,arr+n);



  if (k>=n){

    cout<<0;

  } else if (k==0){

   cout<< cnt;





  }

  else {

  for (int i=n-1;i>=0;i--){

        if (maxm<=k){

        cnt-=arr[i];}

        maxm++;

  }

   cout<<cnt;}



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.562379538076308x):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

    for(int i=0,_i=n-k;i<_i;++i)

        ans+=a[i];

    io<<ans;

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const int MAX = (int)2e5 + 7;

int monsters[MAX];

int main() {

	int n, k;

	cin >> n >> k;

	

	for(int i = 0; i < n; i++)

		cin >> monsters[i];

	

	sort(monsters, monsters + n);

	

	int attacksNo = n - k;

	long long ans = 0;

	for(int i = 0; i < attacksNo; i++)

		ans += (long long)monsters[i];

		

	cout << ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.400192615678906x):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

    for(int i=0,_i=n-k;i<_i;++i)

        ans+=a[i];

    io<<ans;

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>



using namespace std;



#define ll long long



int main()

{

    ll n, k;

    cin >> n >> k;



    if(k >= n)

    {

        cout << 0 << endl;

        return 0;

    }



    vector<ll> health(n);



    for(ll &h : health) cin >> h;



    sort(health.begin(), health.end());



    ll res = 0;

    for(int i = 0 ; i < health.size()-k; ++i)

    {

        res += health[i];

    }



    cout << res << endl;



    return 0;

}




// Faster C++ solution for the same problem (measured speedup: 5.45997558470911x):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

    for(int i=0,_i=n-k;i<_i;++i)

        ans+=a[i];

    io<<ans;

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define rush() int T;scanf("%d",&T);int kase=1;while(T--)

#define all(x) (x).begin(),(x).End()

#define max(x,y) ((x)>(y)?(x):(y))

#define min(x,y) ((x)<(y)?(x):(y))

#define pb(x) push_back(x)

#define mem(a) memset(a,0,sizeof(a))

using namespace std;

using std::bitset;

typedef long long ll;

const ll maxn=1e6+5;

const ll mod=998244353;

const ll INF=0x3f3f3f3f3f3f3f3f;

const long double PI=acos(-1.0);

const long double eps=1e-5;

inline ll read(){ll ans=0,flag=1;char c;c=getchar();while(c<'0' || c>'9'){if(c=='-')flag=-1;c=getchar();}while(c>='0' && c<='9'){ans=ans*10+(ll)(c-'0');c=getchar();}return ans*flag;}

ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}



vector<int>a;



bool cmp(int a,int b)

{

    return a>b;

}



int main()

{

    int n,k;

    cin>>n>>k;

    for(int i=0;i<n;i++)

    {

        int x;

        cin>>x;

        a.push_back(x);

    }

    sort(a.begin(),a.end(),cmp);

    ll sum=0;

    if(k>=n)

        cout<<"0";

    else

    {

        for(int i=k;i<n;i++)

        {

            sum+=a[i];

        }

        cout<<sum;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.414211351973541x):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

    for(int i=0,_i=n-k;i<_i;++i)

        ans+=a[i];

    io<<ans;

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#define lli long long int

#include<climits>

#include<unordered_map>

#include<algorithm>

#include<bitset>

#include<map>

#include<cmath>

#include<queue>

#define pb push_back

#define N (int)(1e5)

using namespace std;

using namespace std;

int main()

{

    int n,k;

    cin>>n>>k;

    lli ans=0;

    vector<lli>arr(n);

    for(int i=0;i<n;i++) cin>>arr[i];

    sort(arr.begin(),arr.end(),greater<int>());

    for(int i=k;i<n;i++)

    {

        ans = ans+arr[i];

    }

    cout<<ans<<endl;

    

    

    



}




// Faster C++ solution for the same problem (measured speedup: 5.433281114263367x):
#include<stdio.h>

#include<algorithm>



#define ll long long



class FIO

{

public:

    template<typename T>FIO& operator >>(T& x){ _R(x);return *this; }

    template<typename T>FIO& operator <<(T x){ _W(x);return *this; }

private:

    char f,c,a[25],i;

    template<typename T>inline void _R(T& x)

    {

        for(f=0;(c=getchar())<48;c==45&&(f=1));

        for(x=c^48;(c=getchar())>47;x=(x<<3)+(x<<1)+(c^48));

        if(f)x=-x;

    }

    template<typename T>inline void _W(T x)

    {

        if(sizeof(x)==1){ putchar(x);return; }

        if(x<0)putchar(45),x=-x;

        if(x>99) {

            for(i=0;x;x/=10)a[i++]=x%10;

            while(i--)putchar(a[i]+48);

        } else if(x>9) putchar(x/10+48),putchar(x%10+48);

        else putchar(x+48);

    }

}io;





ll a[200005];



int main()

{

    ll n,k;

    io>>n>>k;

    for(int i=0;i<n;++i)io>>a[i];

    std::sort(a,a+n);

    ll ans=0;

    for(int i=0,_i=n-k;i<_i;++i)

        ans+=a[i];

    io<<ans;

    return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<long long> a;

int main(){

	int n,k;

	cin>>n>>k;

	long long count=0;

	for(int i=0;i<n;i++){

		long long h;

		cin>>h;

		a.push_back(h);

	}

	if(k>=n){

		cout<<0;

		return 0;

	}

	sort(a.begin(),a.end());

	for(int i=n-k-1;i>=0;i--){

		count+=a[i];

	}

	cout<<count;



} 

// Faster C++ solution for the same problem (measured speedup: 5.228031740852264x):
#include <cstdio>

#include <algorithm>



const int MAXN = 2e5 + 5;



int n, k;

long long int ans;

int arr[MAXN];



int main() {

    scanf("%d%d", &n, &k);

    for (int i = 1; i <= n; ++i) {

        scanf("%d", &arr[i]);

    }

    k = n - k;

    std::sort(arr + 1, arr + n + 1);

    for (int i = 1; i <= k; ++i) {

        ans += arr[i];

    }

    printf("%lld", ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <map>

#include <set>

#include <math.h>

#include <bits/stdc++.h>

using namespace std;



int main()

{

    long long n,k,sum=0;

    cin>>n>>k;

    int arr[n];

    for (int i=0;i<n;i++)

    {



        cin>>arr[i];

    }

    sort (arr,arr+n);

    for (int i=0;i<n-k;i++)

    {

        sum+=arr[i];

    }

    cout<<sum;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.222903915434331x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<utility>

#include<iomanip>

#include<cmath>

#include<algorithm>

#include<cfloat>

#include<functional>

#include<string>

#include<numeric>

#include<vector>

#include<stack>

#include<queue>

#include<set>

#include<map>

#include<cctype>

#include<iterator>

#include <stdio.h>

#include <string.h>

//#include<conio.h>

#define MEGA_MIND ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);

using namespace std;

using ll = long long;

using ld = long double;





int main()

{

	MEGA_MIND

			ll n, k,arr[200005],sum=0;

		cin >> n >> k;

		for (int i = 0; i < n; i++)

		{

			cin >> arr[i];

		}

		sort(arr, arr + n);

		for (int i = n-1; i >= 0; i--)

		{

			if (k>0)

			{

				k--;

			}

			else

			{

				sum += arr[i];

			}

		}

		cout << sum << endl;

	

	return  0;

}




// Faster C++ solution for the same problem (measured speedup: 5.478097212498529x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>



int arr[200'001];



int main()

{

	int N, K;

	long long ans = 0;

	std::cin >> N >> K;

	for (int i = 0; i < N; ++i)

		std::cin >> arr[i];

	std::sort(arr, arr + N);

	for (int i = 0; i < N - K; ++i)

		ans += arr[i];

	std::cout << ans << std::endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.217928032651968x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>



using namespace std;



void Fastio(){

    ios::sync_with_stdio(0);

    cin.tie(0);

    cout.tie(0);

}



int main()

{

    Fastio();

    int n,k; cin>>n>>k;

    long long arr[n];

    for(int i=0; i<n; i++){cin>>arr[i];}

    sort(arr,arr+n);

    long long res=0;

    for(int i=0; i<n-k; i++){res+=arr[i];}

    cout<<res<<'\n';



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.288666302433096x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>

using namespace std;



int main()

{

    int n;

    while(cin >> n)

    {

    int k;

    cin >> k;

    int arr[n];

    for(int i=0;i<n;i++)

    {

        cin >> arr[i];

    }

    sort(arr , arr+n);

    int x=n-k;

    int cnt=0;

    if(x==k)

    {

        cout << 0<<endl;

        cnt++;

    }

    long long int sum=0;

    for(int i=0;i<x;i++)

    {

        sum+=arr[i];

    }

    if(cnt==0)

    {

    cout << sum<<endl;

    }

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.221593338334543x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <algorithm>

#include <cmath>

using namespace std;



int main()

{

    int arr[200005];

    int n,k;

    cin>>n>>k;

    for(int i=0;i<n;i++)

    {

        cin>>arr[i];

    }

    sort(arr,arr+n);

    n-=k;

    long long sum=0;

    for(int i=0;i<n;i++)

    {

        sum+=arr[i];

    }

    cout<<sum;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.288031857703795x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include<queue>

#include <iostream>

#include <algorithm>

#include<cmath>

#include<map>

typedef unsigned long long ll;

using namespace std;

int main()

{

  ll n,k,h,sum=0;

  cin>>n>>k;

  ll arr[n];

  for(int i=0;i<n;i++)

  {

      cin>>h;

      arr[i]=h;

  }

  if(k>n)

  {

      cout<<0;

      return 0;

  }

  sort(arr,arr+n);

  for(int i=0;i<n-k;i++)

  {

      sum+=arr[i];

  }

  cout<<sum;

}


// Faster C++ solution for the same problem (measured speedup: 5.165834808947935x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>

using namespace std;



int main()

{

int n,k;

cin>>n>>k;

int  a[n+1];

for(int i=1;i<n+1;i++)

        cin>>a[i];

sort(a+1,a+n+1,greater<int>());

long long sum=0;



for(int i=k+1;i<n+1;i++)

{



    sum+=a[i];

}

cout<<sum;

 }










// Faster C++ solution for the same problem (measured speedup: 5.210788495476926x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>

using namespace std;



int main()

{long long n,k,counter=0;

cin >> n >> k;

long long arr[n];

for (int i=0; i<n; i++)

{

    cin >> arr[i];

}

sort (arr,arr+n);

if (k>=n)

{

    cout << "0";

}

else

{

    for (int i=0; i<(n-k); i++)

    {

        counter=counter+arr[i];

    }

    cout << counter;

}

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.209156964149413x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <string>

#include<iomanip>

#include <algorithm>

#include <map>

#include <vector>

#include<queue>

#include<math.h>

#include<cmath>

#include<sstream>

#include<set>

#include <map>

#include<string.h>

#include<sstream>

#include<stack>

const double pi = 3.14159265359;

using namespace std;



int main()

{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	long long n, k,arr[200005],sp=0,ans=0;

	cin >> n >> k;

	for (int i = 0; i < n; ++i) {

		cin >> arr[i];

	}

	sort(arr, arr + n);

	sp = n - k;

	for (int i = 0; i < sp; ++i) {

		ans += arr[i];

	}

	cout << ans;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.434380277995652x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <map>

#include <algorithm>

using namespace std;

int main() {

    unsigned long long  mon, special_moves , attacks=0 ;

cin >> mon >> special_moves ;

int monh[mon];

for(int i =0 ; i<mon ; i++){

    cin >> monh[i];

}

sort(monh , monh+mon);

if (special_moves>mon){

        

    }

else if (special_moves>=0){

    if (special_moves==0){

        for(int i=0 ; i<mon ; i++){

            attacks+=monh[i];

        }

    }

    else {

        for(int i=0 ; i<mon-special_moves ; i++ ){

            attacks+=monh[i];

        }

    }

}

cout  << attacks << endl ;

    return 0 ;

}


// Faster C++ solution for the same problem (measured speedup: 5.229559178610356x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cmath>

#include <algorithm>

#include <set>



using namespace std;



int main()

{

   

    long long x, y, sum=0, res=0;



    long long arr[200005];



    cin >> x >> y;



    for (int i = 0; i < x; i++) {



        cin >> arr[i];



        sum += arr[i];

    }



    if (y >= x) {

        cout << 0;



        return 0;



    }





    sort (arr, arr + x);



    x = x - 1;



    for (int i = 0; i < y; i++) {



        res += arr[x];



        x--;



    }





    cout << sum - res;



  

}

// Faster C++ solution for the same problem (measured speedup: 5.36588836573412x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <bits/stdc++.h>

#include<algorithm>

#include<cmath>

using namespace std;



int main()

{

    long long n,s,x;

    cin>>n>>s;

    vector<long long > v;

    for(long long i=0;i<n;i++){

    cin>>x;

    v.push_back(x);

    }sort(v.begin(),v.end());

    long long k=v.size(),sum=0;

    if(s>=n){

       cout<<0;

    }else if(s<n){

    if(s>0){

    for(long long i=(k-1);i>0;i--){

    v[i]=0;

    s--;

    if(s==0)

        break;

    }}

    for(long long i=0;i<n;i++){

     sum+=v[i];

    }

    cout<<sum;

    }

        return 0;

    }


// Faster C++ solution for the same problem (measured speedup: 5.261980316711806x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



const int mxn = 2e5;



int a[mxn + 11];



int main(){

	int n, k;

	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; i++){

		scanf("%d", a + i);

	}

	sort(a, a + n);

	long long ans = 0;

	for (int i = 0; i < n - k; i++){

		ans += a[i];

	}

	printf("%lld\n", ans);

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.151207838139142x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <numeric>



using namespace std;



int main()

{

    unsigned long long int N,K;

    unsigned long long int sum=0,val;

    vector<unsigned long long int> monsters;



    cin>>N>>K;

    for(int i=0;i<N;i++)

    {

        cin>>val;

        monsters.push_back(val);

    }

    if(K>=N)

    {

        cout<<0;

    }

    else

    {



        sort(monsters.begin(),monsters.end());

        for(int i=0;i<N-K;i++)

        {

            sum+=monsters[i];

        }

        cout<<sum;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.261845325492117x):
#include<cstdio>

#include<algorithm>

long long n,k,ans,h[200005];

int main(){

	scanf("%lld%lld",&n,&k);

	for(int i=0;i<n;++i)scanf("%lld",&h[i]);

	std::sort(h,h+n);

	for(int i=0,j=n-k;i<j;++i)ans+=h[i];

	printf("%lld\n",ans);

	return 0;

}