#include <bits/stdc++.h>
using namespace std;
void resuelve() {
  int n, k;
  cin >> n >> k;
  priority_queue<int> q;
  for (int i = 0; i < n; ++i) {
    int valor;
    cin >> valor;
    q.push(valor);
  }
  long long MAX = q.top();
  q.pop();
  for (int i = 0; i < k; ++i) {
    MAX += q.top();
    q.pop();
  }
  std::cout << MAX << '\n';
}
int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; ++i) {
    resuelve();
  }
}
