(defparameter *mod* 1000000007) (defun fact (x) (if (zerop x) 1 (* x (fact (1- x)))) (defun main () (let ((n (read))) (let ((a (loop repeat n collect (read)))) (princ (if (some #'zerop a) -1 (if (every (lambda (x) (<= 1 x 3)) a) (mod *mod* (reduce #'* (mapcar (lambda (x) (expt x (fact x))) a))) 0)))))) (main)