#include <bits/stdc++.h>
using namespace std;
int n,p;
int main() {
cin>>n>>p;
int a[n+5]={0},b[n+5]={0};
for(int i=1;i<=n;++i){
cin>>a[i];
b[i]=a[i];
}
for(int i=1;i<=n-p;++i){
b[i]=a[i+p];
}
for(int i=n-p+1;i<=n;++i){
b[i]=a[i+p-n];
}
for(int i=1;i<=n;++i){
cout<<b[i]<<' ';
}
return 0;
}