def sum_each_to_other(list) return list.first if list.count <= 1 sum_list=[] for i in (0..list.count-2) do sum_list.push list[i] + list[i+1] end sum_each_to_other(sum_list) end a = gets.to_i puts sum_each_to_other(gets.split.map(&:to_i))