#include <bits/stdc++.h>
using namespace std;

struct Node{
	int val;
	Node* next;
	
	Node(int val):val(val),next(nullptr){};
};

Node* removeNode(Node* head,int idx){
	if(head == nullptr){
	   return nullptr;
	};
	if(idx == 0){
		Node* nw = head->next;
		head->next = nullptr;
		return nw;
	}
	Node* curr  = head;
	int cnt = 0;
	while(cnt < idx - 1 && curr != nullptr ){
		curr = curr->next;
		cnt++;
	}
	
	if(curr == nullptr || curr->next == nullptr){
		return head;
	}
	
	Node* temp = curr->next;
	curr->next = temp->next;
	
	delete temp;
	
	return head;
}
Node* LL(vector<int>&a){
	Node* head =  new Node(a[0]);
	Node* curr = head;
	
	for(int i = 1 ; i < a.size();i++){
		curr->next = new Node(a[i]);
		curr = curr->next;
	}
	return head;
}

void print(Node* head){
	Node* temp = head;
	
	while(temp != nullptr){
		cout<<temp->val<<endl;
		temp = temp->next;
	}
}
int main() {
	int n,i ; cin>>n>>i;
	vector<int>a(n);
	
	for(int i = 0;i<n ;i++){
		cin>>a[i];
	}
	
	Node* head = LL(a);
	Node* ans = removeNode(head,i);
	
	print(ans);
	return 0;
}