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