#include<bits/stdc++.h>
using namespace std;
struct node{
int data;
node *next;
node(int d){
data = d;
this->next = NULL;
}
};
node *insert(node *head, int n){
node *tail = head;
if(n>0){
int data;
cin >> data;
node *temp = new node(data);
head = temp;
tail = temp;
}
for(int i = 1; i < n; i++){
int data;
cin >> data;
node *temp = new node(data);
tail->next = temp;
tail = temp;
}
return head;
}
void print(node *head){
while(head!=NULL){
cout << head->data << " ";
head = head->next;
}
}
node *Kappend(node *head, int k){
node *newHead = head, *tail = head;
while(k--)
tail = tail->next;
newHead = tail->next;
tail->next = NULL;
tail = newHead;
while(tail->next!=NULL)
tail = tail->next;
tail->next = head;
return newHead;
}
int main(){
node *head = NULL;
int n;
cin >> n;
head = insert(head, n);
int k;
cin >> k;
k = k%n;
head = Kappend(head, n-k-1);
print(head);
}