stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

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 Would

#define you

#define please



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	int A[100001];

	rep1(i, N) {

		int a;

		cin >> a;

		A[a] = i + 1;

	}

	int daishou[100004] = {};

	daishou[0] = 2;

	daishou[N + 3] = N + 1;



	ll kotae = 0;

	rep1(i, N) {

		int a = A[i];

		int l = daishou[a - 1];

		if (!l) l = a;

		int r = daishou[a + 1];

		if (!r) r = a;

		int l2 = daishou[l - 2];

		if (!l2) l2 = l - 1;

		int r2 = daishou[r + 2];

		if (!r2) r2 = r + 1;



		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;



		daishou[l] = r;

		daishou[r] = l;

	}



	co(kotae);



	Would you please return 0;

}

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

#include<cstdio>

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 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(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;

}



int main() {

	//cin.tie(0);

	//ios::sync_with_stdio(false);





	int N = getint();

	int A[100001];

	rep1(i, N) A[getint()] = i + 1;

	int daishou[100004] = {};

	daishou[0] = 2;

	daishou[N + 3] = N + 1;



	ll kotae = 0;

	rep1(i, N) {

		int a = A[i];

		int l = daishou[a - 1];

		if (!l) l = a;

		int r = daishou[a + 1];

		if (!r) r = a;

		int l2 = daishou[l - 2];

		if (!l2) l2 = l - 1;

		int r2 = daishou[r + 2];

		if (!r2) r2 = r + 1;



		kotae += ((ll)(r2 - r) * (a - l + 1) + (ll)(l - l2) * (r - a + 1)) * i;



		daishou[l] = r;

		daishou[r] = l;

	}



	printf("%lld", kotae);



	Would you please return 0;

}
// Slower C++ solution:
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll idx;

    ll num;

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010];

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){0, -1, -1, 1};

    arr[1] = (Q){1, -1, 0, 2};

    rep(i,0,N){

        arr[i+2] = (Q){i+2, P[i], i+1, i+3};

    }

    arr[N+2] = (Q){N+2, -1, N+1, N+3};

    arr[N+3] = (Q){N+3, -1, N+2, N+4};

    ll pos[100010] = {};

    rep(i,0,N) pos[P[i]] = i+2;



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll lv2 = arr[lv].lv;

        ll rv = arr[p].rv;

        ll rv2 = arr[rv].rv;

        if(lv == 1){

            ans += n * (rv2 - rv) * (p - lv);

        }else if(rv == N+2){

            ans += n * (lv - lv2) * (rv - p);

        }else{

            ans += n * (lv - lv2) * (rv - p);

            ans += n * (rv2 - rv) * (p - lv);

        }

        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}

// Faster C++ solution for the same problem (measured speedup: 1.4844728963400684x):
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010];

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){-1, 1};

    arr[1] = (Q){0, 2};

    rep(i,0,N){

        arr[i+2] = (Q){i+1, i+3};

    }

    arr[N+2] = (Q){N+1, N+3};

    arr[N+3] = (Q){N+2, N+4};

    ll pos[100010] = {};

    rep(i,0,N) pos[P[i]] = i+2;



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll lv2 = arr[lv].lv;

        ll rv = arr[p].rv;

        ll rv2 = arr[rv].rv;

        if(lv != 1){

            ans += n * (lv - lv2) * (rv - p);

        }

        if(rv != N+2){

            ans += n * (rv2 - rv) * (p - lv);

        }



        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}
// Slower C++ solution:
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll idx;

    ll num;

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010];

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){0, -1, -1, 1};

    arr[1] = (Q){1, -1, 0, 2};

    rep(i,0,N){

        arr[i+2] = (Q){i+2, P[i], i+1, i+3};

    }

    arr[N+2] = (Q){N+2, -1, N+1, N+3};

    arr[N+3] = (Q){N+3, -1, N+2, N+4};

    ll pos[100010] = {};

    rep(i,0,N) pos[P[i]] = i+2;



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll lv2 = arr[lv].lv;

        ll rv = arr[p].rv;

        ll rv2 = arr[rv].rv;

        if(lv == 1){

            ans += n * (rv2 - rv) * (p - lv);

        }else if(rv == N+2){

            ans += n * (lv - lv2) * (rv - p);

        }else{

            ans += n * (lv - lv2) * (rv - p);

            ans += n * (rv2 - rv) * (p - lv);

        }

        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}

// Faster C++ solution for the same problem (measured speedup: 1.2024215013839197x):
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    scanf("%lld", &N);

    ll P[100010] = {};

    rep(i,0,N) scanf("%lld", &P[i]);

    vector<Q> arr(100010);

    arr[0] = (Q){-1, 1};

    arr[1] = (Q){0, 2};

    ll pos[100010] = {};

    rep(i,0,N){

        arr[i+2] = (Q){i+1, i+3};

        pos[P[i]] = i+2;

    }

    arr[N+2] = (Q){N+1, N+3};

    arr[N+3] = (Q){N+2, N+4};



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll rv = arr[p].rv;

        if(lv != 1){

            ans += n * (lv - arr[lv].lv) * (rv - p);

        }

        if(rv != N+2){

            ans += n * (arr[rv].rv - rv) * (p - lv);

        }



        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}
// Slower C++ solution:
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll idx;

    ll num;

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010];

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){0, -1, -1, 1};

    arr[1] = (Q){1, -1, 0, 2};

    rep(i,0,N){

        arr[i+2] = (Q){i+2, P[i], i+1, i+3};

    }

    arr[N+2] = (Q){N+2, -1, N+1, N+3};

    arr[N+3] = (Q){N+3, -1, N+2, N+4};

    ll pos[100010] = {};

    rep(i,0,N) pos[P[i]] = i+2;



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll lv2 = arr[lv].lv;

        ll rv = arr[p].rv;

        ll rv2 = arr[rv].rv;

        if(lv == 1){

            ans += n * (rv2 - rv) * (p - lv);

        }else if(rv == N+2){

            ans += n * (lv - lv2) * (rv - p);

        }else{

            ans += n * (lv - lv2) * (rv - p);

            ans += n * (rv2 - rv) * (p - lv);

        }

        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

}

// Faster C++ solution for the same problem (measured speedup: 1.20405691673721x):
/*** author: yuji9511 ***/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> lpair;

const ll MOD = 1e9 + 7;

const ll INF = 1e18;

#define rep(i,m,n) for(ll i = (m); i < (n); i++)

#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)

#define print(x) cout << (x) << endl;

#define print2(x,y) cout << (x) << " " << (y) << endl;

#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};

typedef struct {

    ll lv;

    ll rv;

} Q;

int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    ll N;

    cin >> N;

    ll P[100010] = {};

    rep(i,0,N) cin >> P[i];

    vector<Q> arr(100010);

    arr[0] = (Q){-1, 1};

    arr[1] = (Q){0, 2};

    ll pos[100010] = {};

    rep(i,0,N){

        arr[i+2] = (Q){i+1, i+3};

        pos[P[i]] = i+2;

    }

    arr[N+2] = (Q){N+1, N+3};

    arr[N+3] = (Q){N+2, N+4};



    ll ans = 0;

    rep(n,1,N){

        ll p = pos[n];

        ll lv = arr[p].lv;

        ll rv = arr[p].rv;

        if(lv != 1){

            ans += n * (lv - arr[lv].lv) * (rv - p);

        }

        if(rv != N+2){

            ans += n * (arr[rv].rv - rv) * (p - lv);

        }



        arr[lv].rv = arr[p].rv;

        arr[rv].lv = arr[p].lv;

    }

    print(ans);







    

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

#include <string>

#include <deque>

#include <queue>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

	long long N, K;

	cin >> N >> K;

	priority_queue<long long,vector <long long>,greater<long long>> p;

	int tmp;

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

		cin >> tmp;

		p.push(tmp);

	}

	long long sum = 0;

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

		sum +=  p.top() ;

		p.pop();

	}

	cout << sum;

		//system("pause");

}

// Faster C++ solution for the same problem (measured speedup: 5.4729136506196525x):
#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 <map>

#include <algorithm>

using namespace std;

typedef long long ll;

// using dfs or inorder traverse and savee them then iterate over them to ckeck they are sorted



// Complete the breakingRecords function below.

void minn(int a, int b)

{

    a > b ? cout << b : cout << a;

}



void solve(string s)

{

    

}



int main()

{

    int n, m , k;

    cin >> n >> k;

    vector <ll> v(n,0);

    vector <bool> b(150001,0);

    ll sum = 0;

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

        cin >> v[i];

    }

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

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

        sum += v[i];

    }

    cout << sum;

    



}


// Faster C++ solution for the same problem (measured speedup: 5.571287639399315x):
#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<math.h>

#include<algorithm>

#include<deque>

#include<vector>

#include <iostream>

#include<map>

#include<stack>

#include <string>

using namespace std;

int main()

{

    long long n;

        cin >> n;

        long long k, a=0;

        long long* m = new long long[n];

        long long i = 0;

        cin >> k;

        i = n-1;

        while (i>=0) {

            cin >> m[i];

            i--;

            

        }

        sort(m, m + n);

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

            a += m[i];





        }

        cout << a << endl;





    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.412806098663192x):
#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;



int main()

{

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



long long n,k; cin>>n>>k;

long long arr[n];

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

    cin>>arr[i];



    sort(arr,arr+n,greater<>());

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

{

    arr[i]=0;

}

long long sum=0;

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

{

    sum+=arr[i];

}

cout<<sum<<endl;





return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.474327933833397x):
#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 <string>

#include <algorithm>

#include <cmath>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <deque>

#include <stack>

#include <bitset>

#include <iomanip>

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

#define ll long long



using namespace std;





int solve(int n, int m, int cntr)

{

	if (n == m)

		return cntr;

	if (n > m)

	{

		return cntr;

	}



	return (solve(n * 3, m, ++cntr));

	return (solve(n * 2, m, ++cntr));

}

int main()

{

	assem99;



	ll sum = 0;

	int n, k, arr[200005];

	int cntr = 0;

	cin >> n >> k;

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

		cin >> arr[i];

	if (n <= k)

		cout << '0';

	else

	{

		sort(arr, arr + n);

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

		{

			if (cntr == n - k)

				break;

			sum += arr[i];

			cntr++;

		}



		cout << sum;

	}

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.553269962477848x):
#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 <set>



using namespace std;

int main()

{

   long long n, k ,h ,counter=0 ,sum=0;

   multiset<long long , greater<long long> >st;

   cin>>n>>k;

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

   {

       cin>>h;

       sum+=h;

       st.insert(h);

   }

    multiset<long long , greater<long long> > ::iterator it;

     it=st.begin();



   while(it!=st.end())

   {

       if(k>0)

       {

           sum-=(*it);

           k--;

           it++;

       }

       else if(k==0)

       {

           break;

       }

   }

   cout<<sum;

 /*

   while(it!=st.end())

   {

       cout<<(*it)<<" " ;

       it++;

   }*/



    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.457172786896617x):
#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;

int main()

{

	long long monsters, special_moves;

	cin>>monsters>>special_moves;

	vector <long long> grid;

	long long total = 0;

	for(long long i = 0; i < monsters; i++)

	{

		long long h;

		cin>>h;

		total += h;

		grid.push_back(h);

	}

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



	if(special_moves == monsters)

	{

		cout<<0<<endl;

		return 0;

	}

	int i = monsters - 1;

	while(special_moves > 0 && i >= 0)

	{

		total -= grid[i];

		i--;

		special_moves--;

	}

	cout<<total<<endl;

}

// Faster C++ solution for the same problem (measured speedup: 5.464484772947943x):
#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;

}