In computer science, the maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array, a[1...n], of numbers which has the largest sum. Formally, the task is to find with, such that the sum is maximal. The array usually contains both positive and negative numbers along with 0.