collatz() {
    cnt=0
    j=$1
    while [ $j -ne 1 ] ; do
        cnt=$((cnt+1))
        if [ $((j % 2)) -eq 0 ]; then
            j=$((j / 2))
        else
            j=$((j * 3))
            j=$((j + 1))
        fi
    done
    return_var=$cnt
}

read n
acc=0
for i in `seq 1 $n`; do
    collatz $i
    acc=$((acc + return_var))
    acc=$((acc % 1000000007))
done
echo $acc
