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$d[$N-1]