The group of sequential positive numbers with the highest sum? Given the following list of numbers, find the group of
sequential positive numbers with the highest sum.

Example input:

12 2 35 -1 20 9 76 5 4 -3 4 -5 19 80 32 -1


Example output:

131


The most succinct code wins.

My approach via Perl is 87 chars (with input as command-line args):

print((sort { $b &lt;=&gt; $a } do { push @s, $_ &gt; 0 ? pop(@s) + $_ : 0 for @ARGV; @s })[0]);
APL, 35 characters

i←⎕⋄⌈/{{+/⍵/⍨∧\⍵&gt;0}⍵↓i}¨0,(i≤0)/⍳⍴i


I used Dyalog APL for this. ⎕IO should be set to its default of 1.

Example (note that high-minus, ¯, must be used instead of regular minus):

      i←⎕⋄⌈/{{+/⍵/⍨∧\⍵&gt;0}⍵↓i}¨0,(i≤0)/⍳⍴i
⎕:
      12 2 35 ¯1 20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1
131


Explanation (roughly right-to-left for each expression):


First, we get (and evaluate) the input: i←⎕. (⋄ separates expressions in a single statement.)
(i≤0)/⍳⍴i is an idiom to get the list of the locations of elements of i that are ≤0.

i≤0 returns a vector of binary values, where each element is 1 if the corresponding element in i is ≤0, and 0 otherwise.
⍳⍴i returns a list of integers, from 1 to the shape (length) of i.
The replication function, /, replicates each value in its right argument n times, where n is the corresponding element in its left argument. Because we have a binary list, this just includes or excludes elements (replicating them 0 or 1 times).
We tack a 0 on the beginning, using the concatenation operator (,).

Now, using the example input, we have the vector 0 4 10 12 16. We use the each operator, ¨, to map a function (its left operand) to each element of this list.
The function is a direct function (basically, an anonymous function), and its definition is surrounded with curly braces. Its right argument is represented by the omega symbol, ⍵.
For each element of our vector:

The outermost function, {{ ... }⍵↓i}, returns the vector i, with ⍵ elements dropped (↓) from the beginning. This is then fed to...
The innermost function, {+/⍵/⍨∧\⍵&gt;0}, in slightly less golfed form is {+/(∧\⍵&gt;0)/⍵}.
(∧\⍵&gt;0)/⍵ is similar to the aforementioned idiom. First we generate a list of elements in ⍵ that are above 0. Then, we use the scan operator, \, along with the bitwise-AND function, ∧, to return the list (⍵1 , ⍵1 ∧ ⍵2 , ⍵1 ∧ ⍵2 ∧ ⍵3 , ...). In other words, this list consists of 1's up until the first non-positive element, where it is then all 0's. We use replication as before.
We now use the reduction operator, (also) represented by /, along with the addition function, +, to fold all positive elements in the current list, up to (but not including) the first non-positive one.

Lastly, we fold again, this time with the maximum function, ⌈.


Here are snapshots showing the results of some stages:

      i≤0
0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1

      ⍳⍴i
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

      0,(i≤0)/⍳⍴i
0 4 10 12 16

      {⍵↓i}¨0,(i≤0)/⍳⍴i
 12 2 35 ¯1 20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1  20 9 76 5 4 ¯3 4 ¯5 19 80 32 ¯1  4 ¯5 19 80 32 ¯1  19 80 32 ¯1

      {{(∧\⍵&gt;0)}⍵↓i}¨0,(i≤0)/⍳⍴i
 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0  1 1 1 1 1 0 0 0 0 0 0 0  1 0 0 0 0 0  1 1 1 0   

      {{(∧\⍵&gt;0)/⍵}⍵↓i}¨0,(i≤0)/⍳⍴i
 12 2 35  20 9 76 5 4  4  19 80 32   

      {{+/(∧\⍵&gt;0)/⍵}⍵↓i}¨0,(i≤0)/⍳⍴i
49 114 4 131 0


Hopefully some of this makes a bit of sense!