# Arup Guha
# 7/23/2025
# Solution to 2025 SI@UCF Competitive Programming Camp Conteest #5 Problem: Top K for the Crown

# Process cases.
nC = int(input())
for loop in range(nC):

    # Get basic input.
    toks = input().split()
    n = int(toks[0])
    k = int(toks[1])

    # Read list sort reverse.
    vals = [int(x) for x in input().split()]
    vals.sort(reverse=True)

    # Very easy in Python!
    print(sum(vals[:k]))
