#!/bin/python3

import math
import os
import random
import re
import sys


def left_Rotate(a,n,d):
    for i in range(d):
        f = a[0]
        a.remove (f)
        a.append(f)
    return a 


if __name__ == '__main__':
    nd = input().split()

    n = int(nd[0])

    d = int(nd[1])

    a = list(map(int, input().rstrip().split()))
    ans=left_Rotate(a,n,d)
    asnwer  =' '.join(map(str, ans)) 
    print (asnwer)
