#include <bits/stdc++.h>
using namespace std;
long long t, n, k;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  ;
  while (t--) {
    cin >> n >> k;
    priority_queue<long long> q;
    for (long long i = 1; i <= n; i++) {
      long long x;
      cin >> x;
      q.push(x);
    }
    while (k != 0) {
      k--;
      long long thu1 = q.top();
      q.pop();
      long long thu2 = q.top();
      q.pop();
      q.push(0);
      q.push(thu1 + thu2);
    }
    cout << q.top() << "\n";
  }
}
