import java.util.ArrayList;
import java.util.Scanner;
/**
* 一个数组A中存有N(>0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(≥0)个位置,
* 解题重点:
* 1.arrayList的remove执行后会返回删除的数据
*/
public class Basic1008 {
public static void main(String[] args) {
ArrayList<Integer> list = new ArrayList<>();
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int M = in.nextInt();
for (int i = 0; i < N; i++) {
list.add(in.nextInt());
}
while (M != 0) {
int t = list.remove(list.size() - 1);
list.add(0, t);
M--;
}
for (int i = 0; i < list.size(); i++) {
if (i != list.size() - 1)
System.out.print(list.get(i) + " ");
else
System.out.print(list.get(i));
}
}
}