#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k, l;
    cin >> n >> k;
    vector<int> barrel;
    for (int i = 0; i < n; i++) {
      cin >> l;
      barrel.push_back(l);
    }
    sort(barrel.begin(), barrel.end());
    long long int resp = 0;
    k++;
    while (k--) {
      resp += barrel.back();
      barrel.pop_back();
    }
    cout << resp << endl;
  }
  return 0;
}
