#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    long long int n, k;
    cin >> n >> k;
    long long int arr[n];
    for (long long int j = 0; j < n; j++) {
      cin >> arr[j];
    }
    sort(arr, arr + n);
    for (long long int j = 1; j <= k; j++) {
      arr[n - 1] += arr[n - j - 1];
      arr[n - j - 1] = 0;
    }
    cout << arr[n - 1] << endl;
  }
}
