(defun main (&rest argv) (declare (ignorable argv)) (let* ((n (read)) (v (make-array n)) (dp (make-array (1+ n) :initial-element (cons 0 0)))) (dotimes (i n) (setf (aref v i) (read))) (loop for i from 1 to n do (setf (aref dp i) (cons (max (car (aref dp (1- i))) (cdr (aref dp (1- i)))) (+ (car (aref dp (1- i))) (aref v (1- i))))) finally (format t "~D~%" (max (car (aref dp n)) (cdr (aref dp n))))))) (main)