I need the length of the shortest nonempty contiguous subarray whose sum is at least the given target. The values may be positive, zero, or negative, and the function should return -1 when no qualifying subarray exists. A natural first thought is a sliding window: extend the right edge until the sum reaches the target, then move the left edge forward while the condition still holds. That is a good solution when every value is nonnegative, because moving the right edge cannot reduce the sum and moving the left edge cannot increase it.

But wait, the input explicitly permits negative numbers, so that monotonic behavior is unavailable. With [2, -1, 2] and target 3, extending a window can decrease its sum before it increases again. More seriously, a window that currently falls short can contain an initial negative segment that should be discarded even before the target is reached. For [-4, 5] with target 5, the whole prefix has sum 1, yet the last element alone is a valid answer of length one. A standard positive-only window would never enter its shrinking phase and would miss that answer.

Prefix sums provide a formulation that works regardless of signs. Let prefix[j] be the sum of the first j values, with prefix[0] = 0. The sum of the half-open subarray from i to j is prefix[j] - prefix[i], and its length is j - i. For each right boundary j, we want an earlier index i with prefix[i] <= prefix[j] - target, preferably as far right as possible because a later starting point gives a shorter subarray. Looking at all earlier prefixes would be correct but quadratic, so the remaining question is which earlier indices can be discarded safely.

Suppose i is earlier than k and prefix[i] is at least prefix[k]. For any future endpoint j, the subarray starting at k has sum at least as large as the one starting at i, because subtracting the smaller prefix leaves a larger difference. It is also shorter because k is later. Therefore i can never be a better starting point than k for any future endpoint. Once k is available, i is dominated and can be removed. Keeping candidate indices in increasing index order and strictly increasing prefix-sum order lets us remove dominated candidates from the back as each new prefix arrives.

There is a second safe removal rule at the front. If the current prefix minus the prefix at the first candidate reaches the target, we have found a valid subarray and can update the best length. That candidate can then be removed permanently. Any later endpoint would make the subarray starting there longer than the one just examined. Even if a later endpoint gives a larger sum, it cannot improve the length already recorded for that starting index. We repeat this front removal while candidates continue to satisfy the target, because later candidates may produce an even shorter valid subarray ending at the same position.

A deque supports both kinds of removal efficiently. Its front is the smallest candidate prefix sum, so if the front does not satisfy the inequality, none of the later candidates can satisfy it either. When the front does satisfy it, remove it, measure its length, and examine the next candidate. At the back, compare the new prefix sum against the last retained one and remove any last value that is no smaller. Appending the current index restores strict increase. Each index enters once and can leave only once, which is the reason the total deque work is linear.

Let me re-check the order of those operations, because the nonempty requirement makes it significant. We should test existing candidates before appending the current index. Otherwise, when target is zero or negative, the current prefix could pair with itself and produce a subarray of length zero. By evaluating the deque first, every candidate index is strictly less than the current endpoint. The dominated-prefix removals can then happen before appending the current index. If the current index removes an older equal prefix, it offers every future endpoint the same sum with a shorter length, so equality belongs in the back-removal condition.

For [2, -1, 2] and target 3, the prefix sums are 0, 2, 1, 3. Start with no candidates. At prefix index zero, append zero. At index one, the difference from zero is 2, which is too small, so append one. At index two, the new prefix sum is 1; index one has prefix sum 2 and is dominated, so remove it and retain candidates zero and two. At index three, subtracting prefix zero gives 3, so record length three and remove zero. The remaining candidate does not reach the target. The final answer is three, as expected.

For [-4, 5] and target 5, the prefixes are 0, -4, 1. When -4 arrives, it removes prefix zero from the back because it is a later, smaller prefix. At endpoint two, the difference 1 - (-4) reaches 5, yielding length one. This is precisely the case that defeated the naive sliding window. We did not need to guess when a negative initial segment should be discarded; the dominance relation expressed that decision directly and remains valid for all future endpoints, not just the current example.

The deque invariant is now clear. Before evaluating each new endpoint, candidate indices increase from front to back, their prefix sums strictly increase, and every removed index has either already produced its shortest potentially useful qualifying interval or been replaced by a later prefix with no larger value. Therefore no optimal future answer is lost. Processing every endpoint and updating the best length for all qualifying front candidates eventually examines an answer no longer than any feasible optimum. Since every recorded length corresponds to an actual qualifying nonempty subarray, it cannot be shorter than the optimum, so the result is exact.

We can keep the entire prefix array for clarity. That requires O(n) storage, as does the deque in the worst case. It is possible to keep pairs of index and running sum in the deque and avoid a separate prefix array, but the asymptotic storage bound remains O(n), and the array notation matches the derivation directly. The implementation below uses a running total and stores pairs instead. This is still the same invariant; each pair records the prefix value at a candidate boundary. It also avoids creating a second collection solely to retrieve a candidate's sum.

The best answer starts as n + 1, a value larger than every possible nonempty subarray length. If it remains unchanged, return -1. For empty input, the only prefix is zero and no pair of distinct boundaries is considered, so the function also returns -1. Negative targets work without an additional branch because the front condition still tests the exact inequality. The loop never returns zero length, since the new endpoint is appended only after all matching work. With the earlier sliding-window assumption corrected, the final function is:

```python
from collections import deque


def shortest_subarray_at_least(values, target):
    candidates = deque([(0, 0)])
    prefix = 0
    best = len(values) + 1
    for right, value in enumerate(values, 1):
        prefix += value
        while candidates and prefix - candidates[0][1] >= target:
            left, _ = candidates.popleft()
            best = min(best, right - left)
        while candidates and candidates[-1][1] >= prefix:
            candidates.pop()
        candidates.append((right, prefix))
    return best if best <= len(values) else -1
```
