Let = sum of first elements, with . The sum of subarray is . You want with , reducing . Rearranging: . For each , you're looking for the largest such that .
But you also want as small as possible, which means you want as large as possible while still satisfying the constraint.