;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro nlet (name args &body body)
  (labels ((ensure-list (x) (if (listp x) x (list x))))
    (let ((args (mapcar #'ensure-list args)))
      `(labels ((,name ,(mapcar #'car args) ,@body))
         (,name ,@(mapcar #'cadr args))))))

(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  ;; (return-from read-fixnum 0)
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (the fixnum (* result 10))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(declaim (ftype (function * (values (array (integer 0 #.most-positive-fixnum) (*))))
                enum-divisors))
(defun enum-divisors (x)
  "Enumerates divisors of X in ascending order"
  (declare #.OPT (fixnum x))
  (setf x (abs x))
  (let* ((sqrt (isqrt x))
         (res (make-array sqrt
                          :element-type '(integer 0 #.most-positive-fixnum)
                          :fill-pointer 0)))
    (loop for i from 1 to sqrt
          do (multiple-value-bind (quot rem) (floor x i)
               (when (zerop rem)
                 (vector-push-extend i res)
                 (unless (= i quot)
                   (vector-push-extend quot res)))))
    res))

(declaim (inline unique-merge))
(defun unique-merge (element-type vec1 vec2 predicate)
  (declare (function predicate))
  (let ((res (make-array 0
                         :element-type element-type
                         :fill-pointer 0)))
    (let ((i1 1)
          (i2 0)
          (pos -1))
      (declare ((integer -1 #.most-positive-fixnum) i1 i2 pos))
      (loop (if (= i1 (length vec1))
                (loop (when (= i2 (length vec2))
                        (return-from unique-merge res))
                      (when (or (= -1 pos)
                                (funcall predicate (aref res pos) (aref vec2 i2)))
                        (vector-push-extend (aref vec2 i2) res)
                        (incf pos))
                      (incf i2))
                (when (= i2 (length vec2))
                  (loop (when (= i1 (length vec1))
                          (return-from unique-merge res))
                        (when (or (= -1 pos)
                                  (funcall predicate (aref res pos) (aref vec1 i1)))
                          (vector-push-extend (aref vec1 i1) res)
                          (incf pos))
                        (incf i1))))
            (if (funcall predicate (aref vec1 i1) (aref vec2 i2))
                (progn
                  (when (or (= -1 pos)
                            (funcall predicate (aref res pos) (aref vec1 i1)))
                    (vector-push-extend (aref vec1 i1) res)
                    (incf pos))
                  (incf i1))
                (progn
                  (when (or (= -1 pos)
                            (funcall predicate (aref res pos) (aref vec2 i2)))
                    (vector-push-extend (aref vec2 i2) res)
                    (incf pos))
                  (incf i2)))))))

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (as (make-array n :element-type 'uint32)))
    (declare (uint32 n))
    (dotimes (i n)
      (setf (aref as i) (read-fixnum)))
    (let* ((div1 (sort (enum-divisors (aref as 0)) #'>))
           (div2 (sort (enum-divisors (aref as 1)) #'>))
           (div (unique-merge 'uint32 div1 div2
                              (lambda (x y)
                                (declare (uint32 x y))
                                (> x y)))))
      (declare ((array uint32 (*)) div))
      (loop for d across div
            when (>= (count-if (lambda (a) (zerop (mod (the uint32 a) d))) as)
                     (- n 1))
            do (println d)
               (return-from main)
            finally (error "Huh?")))))

#-swank(main)


Measured memory_bytes: 26724