(let* ((n (string->number (read-line))) (v (list->vector(map string->number (string-split (read-line) " ")))) (c (make-vector 1001 -1))) (letrec ((calc-max (lambda (i) (if (< 0 (vector-ref c i)) (vector-ref c i) (cond ((eq? i 1) (let ((e (vector-ref v 0))) (vector-set! c i e) e)) ((eq? i 2) (let ((e (max (vector-ref v 0) (vector-ref v 1)))) (vector-set! c i e) e)) (else (let ((e (max (calc-max (- i 1)) (+ (vector-ref v (- i 1)) (calc-max (- i 2)))))) (vector-set! c i e) e))))))) (print (calc-max n))))