Find the contiguous run of numbers with the largest sum, such as the best stretch of daily profit and loss. Kadane's algorithm does it in one pass: at each position, either extend the best run ending at the previous position or start fresh.
Implement max_subarray(nums) returning (best_sum, start, end), where nums[start:end+1] is the best run. The run must contain at least one element, so all-negative input returns the largest single value. If several runs tie, return the one that starts first, and among those the shortest. Raise ValueError for an empty list.