(defun main (&rest argv)
  (declare (ignorable argv))
  (let* ((n (read))
         (a (make-array n))
         (b))
    (dotimes (i n) (setf (aref a i) (cons i (read))))
    (sort a #'< :key #'cdr)
    (when (/= (1- n) (car (aref a (1- n))))
          (setf b (aref a (1- n))
                (aref a (1- n)) (aref a (- n 2))
                (aref a (- n 2)) b))
    (dotimes (i n)
      (format t "~d " (cdr (aref a i))))
    (terpri)))

(main)