(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)))) (labels ((sub (xs &optional (res 1)) (cond ((null xs) (mod *mod* res)) ((> res *mod*) -1) (t (sub (rest xs) (* (expt (first xs) (fact (first xs))) res)))))) (princ (if (some #'zerop a) -1 (if (every (lambda (x) (<= 1 x 3)) a) (sub a) -1))))))) (main)