n,k=gets.chomp.split.map(&:to_i)

arr = []
n.times do
  arr << gets.chomp.to_i
end

all_arr = []
n.times do
  all_arr << arr
  arr.rotate!
end

save_arr = []
all_arr.each do |one|
  new_arr = []
  new_arr << one[0]
  one.each_with_index do |a, i|
    if i != 0
      if (new_arr.last - a).abs <= k
        new_arr << a
      end
    end
  end
  if save_arr.length - new_arr.length<0
    save_arr = new_arr
    p save_arr
  end
end
