(defvar n (read)) (defparameter a (sort (apply #'vector (cons -100000000 1) (loop for i from 1 to (1- n) collect (cons (read) i))) #'(lambda (x y) (< (car x) (car y))))) (defvar f nil) (defparameter ans (make-array n)) (loop for i from 1 to (1- n) until f do (if (<= (car (aref a i)) i) (setf (aref ans (cdr (aref a i))) (1+ (- i (car (aref a i))))) (setq f t))) (if f (progn (princ "NO") (fresh-line)) (progn (princ "YES") (fresh-line) (loop for i from 1 to (1- n) do (princ (aref ans i)) (fresh-line)))) ;(princ a)