There are two cases. Case : the max subarray doesn't wrap. Standard Kadane's gives you this.
Case : the max subarray wraps around. A wrapping subarray takes elements from both ends and skips a chunk in the middle. That middle chunk is the minimum subarray. So the wrapping max equals totalSum - minSubarray.
Run both max-Kadane and min-Kadane in a single pass. Your answer is max(maxKadane, totalSum - minKadane). One edge case: if all numbers are negative, minKadane equals totalSum, making the wrapping case . In that scenario, just return maxKadane.