------
## 最终结论
```python
def max_difference(t, test_cases):
    results = []
    for case in test_cases:
        n, k, a = case
        a.sort(reverse=True)
        for i in range(1, k + 1):
            a[0] += a[i]
            a[i] = 0
        results.append(a[0] - min(a))
    return results

# Read input
t = int(input())
test_cases = []
for _ in range(t):
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    test_cases.append((n, k, a))

# Calculate and print results
results = max_difference(t, test_cases)
for result in results:
    print(result)
```