(defconstant +mod+ 1000000007) (defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (m (if (> n 4) 4 (1- n))) (dp (make-array (list 5 5) :initial-contents '((0 0 0 0 0) (1 0 1 2 0) (0 1 1 0 0) (0 0 1 1 0) (0 0 0 0 0))))) (loop for i from 5 to n do (setf (aref dp 1 4) (mod (+ (aref dp 2 3) (aref dp 3 3)) +mod+) (aref dp 2 4) (mod (+ (aref dp 1 2) (aref dp 3 2)) +mod+) (aref dp 3 4) (mod (+ (aref dp 1 1) (aref dp 2 1)) +mod+)) (loop for j from 1 to 3 do (setf (aref dp j 1) (aref dp j 2) (aref dp j 2) (aref dp j 3) (aref dp j 3) (aref dp j 4)))) (format t "~d~%" (mod (+ (aref dp 1 m) (aref dp 2 m) (aref dp 3 m)) +mod+)))) (main)