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