(let* ((n (read))
       (lst (loop :repeat n :collect(read)))
       (max (reduce #'max lst))
       (cnt (= (count max lst) 1)))
  (mapcar (lambda (k) (format t "~A~%" (if (= max k) (if cnt (1- max) max) max))) lst))