#include <stdio.h>
#include <stdlib.h>
#define N 10005
int a[N];
int cmp(const void* a, const void* b)
{
return *(int*)a - *(int*)b;
}
void swap(int* a, int* b)
{
int t;
t = *a;
*a = *b;
*b = t;
}
int main(void)
{
int n, m;
scanf("%d", &n);
scanf("%d", &m);
int i, j, k;
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
for (k = 0; k < m; k++)
{
for (i = n; i >= 1; i--)
{
for (j = n - 1; j >= 1; j--)
if (a[j] < a[i])
{
swap(&a[i], &a[j]);
qsort(a + j + 1, n - j, sizeof(int), cmp);
i = j = 0;
}
}
}
for (i = 1; i <= n; i++)
printf("%d ", a[i]);
}