n, k = map(int, input().split()) current = list(map(int, input().split())) steps_remaining = k while steps_remaining > 0: m = current[0] rotate_length = m + 1 if rotate_length > n: rotate_length = n # Generate next array after one step rotated_part = current[1:rotate_length] + [current[0]] remaining_part = current[rotate_length:] next_array = rotated_part + remaining_part next_m = next_array[0] if next_m == m: # Calculate effective steps effective_steps = (steps_remaining - 1) % (m + 1) # Apply effective_steps rotations to the first m+1 elements of next_array rotated_part_initial = next_array[:m+1] shift = effective_steps % (m + 1) rotated_part_after = rotated_part_initial[shift:] + rotated_part_initial[:shift] # Update current array current = rotated_part_after + next_array[m+1:] steps_remaining = 0 else: current = next_array steps_remaining -= 1 print(' '.join(map(str, current)))