if __name__=='__main__':
input1 = input()
input2 = input()
len,off = input1.split(' ')
len = int(len)
off = int(off)%len
lst = [int(i) for i in input2.split(' ')]
tmp = lst[-off:]
res = tmp+lst[:-off]
for index,item in enumerate(res):
if index == len-1:
print(item)
break
print(item,end = ' ')
exit(0)
