(let* ((n (read))
       (a (loop repeat n
                collect (read)))
       (lcma (lcm a))
       (gcda (gcd a)))
  (labels ((f (m)
             (apply #'+
                    (mapcar #'mod
                            (loop repeat n
                                  collect m)
                            a))))
    (princ
      (apply #'max (loop for m from 1 to lcma
                         when (not (zerop (mod m gcda)))
                         collect (f m))))))