def f(n) xs=gets.split.map{|e| (e.to_i-2023).abs} no=[] 1.upto(n){|i| no<<i } puts xs.zip(no).sort[0][1] end n=1 while 0<n n=gets.to_i break if n==0 f(n) end
2 123 4567 3 2024 2020 2023 5 2020 2020 2021 2024 2026 3 1599 2222 1599 8 2 2 3 3 4 4 5 1 4 7777 6666 8888 9999 0