Lisp Array Change
(defun array-change (a)
(let ((vec (coerce a 'vector))
(min 0))
(dotimes (k (1- (length vec)))
(when (>= (aref vec k) (aref vec (1+ k)))
(let ((dif (+ (- (aref vec k) (aref vec (1+ k))) 1)))
(incf (aref vec (1+ k)) dif)
(incf min dif))))
min))
This moves left to right and bumps values only when needed so the array becomes strictly increasing.