max subarray, buy and sell stock