
///              B I S M I L L A H I R  R A H M A N I R  R A H I M

#include<bits/stdc++.h>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef bool                      boo;
typedef int                       li;
typedef long long int             ll;
typedef unsigned long long int    l1;
typedef double                    db;
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

typedef vector < li >                   vli;
typedef vector < ll >                   vll;
typedef set < li >                      sli;
typedef set < ll >                      sll;
typedef pair < li , li >                pli;
typedef pair < ll , ll >                pll;
typedef map < li ,li >                  mli;
typedef map < ll ,ll >                  mll;
typedef vector < pair < li , li > >     vpi;
typedef vector < pair < ll , ll > >     vpl;

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#define tc                        int t;cin>>t;while(t--)
#define inp_i(a,n)                for(i=0; i<n ;i++) cin>>a[i]
#define lp(i,a,b)                 for(i=a;i<b;i++)
#define len(z)                    z.begin(),z.end()
#define faster                    ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define input_txt                 freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define nl                        <<endl
#define spc                       <<" "
#define sp                        <<" "<<
#define co(x)                     cout<<x nl
#define sz(a)                     a.size()
#define cy                        cout<<"YES" nl
#define cn                        cout<<"NO" nl
#define pb                        push_back
#define F                         first
#define S                         second
#define pi                        2*acos(0.0)
#define clr(z)                    z.clear()
#define rn                        return
#define gcd(a,b)                  __gcd(a,b)
#define mem(b,z)                  memset(b,z,sizeof(b))
#define fixed(x)                  fixed<<setprecision(x)
const int lx=3e5+123;

void solve()
{
    li n, k, x;
    cin>>n>>x;
    while(n--)
    {
        cin>>k;
        if(k != x) cout<<k spc;
    }
    cout nl;
}

int main()
{
faster

solve();
// A L H A M D U L I L L A H
// 1 2 3 2 1

}

/*
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
*/

#include <bits/stdc++.h>
using namespace std;

// #include <atcoder/all>
// using namespace atcoder;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;


void solve(long long N, long long K, std::vector<long long> a){
    map<int, int> cnt;
    int mx = 0;
    rep(i, N) {
        cnt[a[i]]++;
        mx = max<int>(mx, a[i]);
    }
    ll ans = 0;
    while (1) {
        int n = -1;
        rep(i, mx + 1) {
            if (cnt[i]) {
                n = i;
                cnt[i]--;
            } else {
                break;
            }
        }
        ans += n + 1;
        K--;
        if (n == -1 || K == 0) {
            break;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, K, std::move(a));
    return 0;
}
