(defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (a (make-array n :element-type 'integer)) (dp (make-array (1+ n) :element-type 'integer :initial-element 0)) (res n)) (dotimes (i n) (setf (aref a i) (read))) (sort a #'<) (loop for i from n downto 0 do (when (and (< (+ i 1) n) (= (+ (aref a i) 2) (aref a (+ i 1)))) (setf (aref dp i) (1+ (aref dp (+ i 1))))) (when (and (< (+ i 2) n) (= (+ (aref a i) 2) (aref a (+ i 2)))) (setf (aref dp i) (1+ (aref dp (+ i 2)))))) (loop for i below (1- n) when (/= (1+ (aref a i)) (aref a (1+ i))) do (incf res (1+ (aref dp (1+ i))))) (format t "~d~%" res))) (main)