@1=($2[2]=1)x2;for$i(3..($n=<>)){($$_[$i]=${$_%3+1}[$i-$_]+${($_+1)%3+1}[$i-$_])%=$%=1e9+7for 1..3};print+($1[$n]+$2[$n]+$3[$n])%$%