eval"N,*V="+`dd`.split*?, (N-3).times{|i|V[i+3]+=V[i,2].max}==0&&V[-1]+=V[0] p V.max