Given an integer array nums (values may be negative) and an integer T, return the length of the shortest non-empty contiguous subarray whose sum is at least T; return -1 if no such subarray exists. Optimize for n up to 200,000. Explain your approach, prove its correctness, analyze time and space complexity, and implement an O(n) solution.