sub max{$_[$_[1]>$_[0]]} $N=<>; @V=glob<>; @d=(@V[0,1],$V[0]+$V[2]); $d[$_]=max($d[$_-3],$d[$_-2])+$V[$_]for 3..$N-1; print$N==1?$d[0]:max(@d[$N-1,$N-2])