gets arr = gets.chomp.split.map(&:to_i) puts ! (arr.size/2).odd? ? (arr.sort![arr.size/2-1] + arr.sort![arr.size/2]) / 2 : arr.sort![arr.size/2]