Max subarray

Input an int array, no matter positive or negative number. Calculate the maximal sum of subarray and ouput the maximal subarray.