#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    long long int x, y;
    priority_queue<long long int> pq;
    for (int i = 0; i < n; i++) {
      cin >> x;
      pq.push(x);
    }
    while (!pq.empty() && (k-- > 0)) {
      x = pq.top();
      pq.pop();
      y = pq.top();
      pq.pop();
      pq.push(x + y);
    }
    cout << pq.top() << endl;
  }
  return 0;
}
