program main
    implicit none
    integer(16) :: i, n, mat(6, 6), current(6, 6), m = 1000000007
    mat = 0
    current = 0
    do i = 1, 5
        mat(i, i + 1) = 1
        mat(i, 1) = 166666668
    end do
    mat(6, 1) = 166666668
    do i = 1, 6
        current(i, i) = 1
    end do
    read *, n
    do while (n >= 1)
        if (mod(n, 2) == 1) then
            current = mod(matmul(current, mat), m)
        end if
        mat = mod(matmul(mat, mat), m)
        n = n / 2
    end do
    print *, current(1, 1)
end program main