#include <bits/stdc++.h>
using namespace std;
int main() {
  int numTests, numBar, numPour;
  cin >> numTests;
  for (int i = 1; i <= numTests; i++) {
    cin >> numBar >> numPour;
    long long barV[numBar];
    for (int j = 0; j < numBar; j++) {
      cin >> barV[j];
    }
    if (numBar == 1) {
      cout << barV[0];
      break;
    }
    sort(barV, barV + numBar);
    for (int j = numBar - 2; j >= 0 && numPour > 0; j--) {
      barV[numBar - 1] += barV[j];
      barV[j] = 0;
      numPour--;
    }
    cout << barV[numBar - 1] << '\n';
  }
  return 0;
}
