n, m = map(int, input().split()) a = list(map(int, input().split())) print(*a[-m:])