#include <bits/stdc++.h>



using namespace std;

const int N = 2e5 + 5;
pair<int, bool> a[N];

int main() {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i<=n; i++) {
        cin >> a[i].first;
    }
    for (int i = 2; i<=n; i++) {
        if (a[i-1].first > a[i].first)
            a[i-1].second = true;
    }
    for (int i = 1; i<=n; i++) {
        if (!a[i].second)
            cout << a[i].first << " ";
    }
    return 0;
}