Given an integer array nums, return the largest possible sum of any non-empty contiguous subarray. The solution should use Kadane's Algorithm, which scans the array once and decides at each position whether to extend the current subarray or start a new one.
def max_subarray(nums):