Lisp Max Slice Sum
(defun max-slice-sum (a)
(let ((tmp most-negative-fixnum)
(max most-negative-fixnum))
(dolist (v a)
(setf tmp (max (+ tmp v) v))
(setf max (max max tmp)))
max))
This is a Kadane-style scan: keep the best running sum and the best overall sum while moving once through the array.