#include
using namespace std;
class node{
public:
long long int data;
node *next;
node(long long int value){
data=value;
next=NULL;
}
};
void insertAt_tail(node*&head,long long value){
if(head==NULL){
head= new node(value);
return;
}
node n=new node(value);
nodetemp=head;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next=n;
}
void print(node head){
while(head!=NULL){
cout<data<<" ";
head=head->next;
}
}
node * append(node * head,long long k){
node slow=head;
node* fast=head;
long long count=0;
while(count<k){
fast=fast->next;
count++;
}
while(fast->next!=NULL){
fast=fast->next;
slow=slow->next;
}
node *n=slow->next;
slow->next=NULL;
fast->next=head;
return n;
}
int main(){
node* head=NULL;
long long n,k,a;
cin>>n;
for( long long int i=0;i<n;i++){
cin>>a;
insertAt_tail(head,a);
}
cin>>k;
if(k>=n){
k=k%n;
}
head=append(head,k);
print(head);
return 0;
}