#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
typedef long long ll;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

#define INCANT cin.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define out(a) cout << a << endl
#define PRINT(V) for (auto v : (V)) cout << v << " "

const int MOD = 1000000007;
const double PI = acos(-1.0);

void solve() {
    int K, N;
    cin >> N >> K;
    vector<int> p(N);
    rep(i, N) cin >> p.at(i);
    sort(all(p));
    rep(i, K){
        if(i < K-1) {
            cout << p[i] << " ";
        }else{
            cout << p[i] << endl;
        }
    }
}
int main() {
    INCANT;
    solve();
    return 0;
}


