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