Prefix Sum +  DP  + Monotonic Queue
```javascript []
function findMaximumLength(nums) {
  const n = nums.length;
  const dp = Array(n + 1).fill(0);
  const prefixSums = [0];

  for (let i = 0; i < nums.length; i++) {
    prefixSums.push(prefixSums.at(-1) + nums[i]);
  }

  const queue = [];
  let prev = 0;

  for (let i = 1; i <= n; i++) {
    // Remove elements from the front of the queue
    while (queue.length && queue[0][0] >= -prefixSums[i]) {
      [, prev] = queue.shift();
    }

    // Update dp
    dp[i] = dp[prev] + 1;

    // Caculate cost
    const cost = -2 * prefixSums[i] + prefixSums[prev]

    // If front less than  <= cost
    while (queue.length && queue.at(-1)[0] <= cost) {
      queue.pop();
    }

    // Add the current cost and index to the queue
    queue.push([cost, i]);
  }

  return dp[n];
}
```
['Array', 'Dynamic Programming', 'Queue', 'Prefix Sum', 'Monotonic Queue', 'JavaScript']