human
Write me a the Python program you requested given the following:
I found an interesting problem on https://leetcode.com/problems/shortest-subarray-with-sum-at-least-k/:
Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K.
If there is no non-empty subarray with sum at least K, return -1.
 


Example 1:
Input: A = [1], K = 1
Output: 1

Example 2:
Input: A = [1,2], K = 4
Output: -1

Example 3:
Input: A = [2,-1,2], K = 3
Output: 3

 
Note:

1 <= A.length <= 50000
-10 ^ 5 <= A[i] <= 10 ^ 5
1 <= K <= 10 ^ 9

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is the Python program you requested.

class Solution:
    def shortestSubarray(self, A: List[int], K: int) -> int:
        
        
        preSum = [0]
        for e in A:
            preSum.append(preSum[-1] + e)
        
        min_len = sys.maxsize
        
        
        #0 2 1 3 7 
        
        #0 1 3 7
        
        q = collections.deque([])
        for i in range(len(preSum)):
            while q and preSum[q[-1]] > preSum[i]:
                q.pop()
            while q and preSum[i] - K >= preSum[q[0]]:
                min_len = min(min_len, i-q.popleft())       

            q.append(i)
        
        return min_len if min_len != sys.maxsize else -1