import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] line = scanner.nextLine().trim().split("\\s+");
String[] split = scanner.nextLine().trim().split("\\s+");
int n = Integer.parseInt(line[0]);
int m = Integer.parseInt(line[1]);
if ( m > n && m%n != 0){
m = m%n;
}
if (n >= 0 && n <= 100 && m >=0){
if (m%n == 0){
for (int i = 0; i < n; i++) {
if (i != n-1){
System.out.print(split[i] + " ");
} else {
System.out.print(split[i]);
}
}
} else {
for (int i = n - m; i < n; i++) {
System.out.print(split[i] + " ");
}
for (int i = 0; i < n - m; i++) {
if (i != n-m-1){
System.out.print(split[i] + " ");
} else {
System.out.print(split[i]);
}
}
}
}
}
}