#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T;
  cin >> T;
  while (T--) {
    long long n, k;
    cin >> n >> k;
    long long arr[n];
    for (long long i = 0; i < n; i++) cin >> arr[i];
    sort(arr, arr + n, greater<long long>());
    for (long long i = 0; i < k; i++) arr[0] += arr[i + 1];
    cout << arr[0] << "\n";
  }
  return 0;
}
