include[HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
int n,m;
const int N=1e5+10;
int q[N];
int cnt;
void down(int x)
{
int a=x;
if(2x<=cnt && q[2x]<q[a]) a=2x;
if(2x+1<=cnt && q[2x+1]<q[a]) a=2x+1;
if(a!=x)
{
swap(q[a],q[x]);
down(a);
}
}
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++) scanf(“%d”,&q[i]);
cnt=n;
for(int i=n/2;i;i–) down(i);
while(m–)
{
printf(“%d “,q[1]);
q[1]=q[cnt–];
down(1);
}
puts(“”);
return 0;
}