gets a=gets.split.map &:to_i a[-2]=a[-3]+a.pop while a[3] a[a[1]==0?1:2,2]=[]if a[2]==0 puts [a.size-1,a*" "]