#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  sort(arr.begin(), arr.end());
  int i = n - 2;
  while (k > 0) {
    arr[n - 1] += arr[i];
    arr[i] = 0;
    i--;
    k--;
  }
  long long ans = arr[n - 1];
  cout << ans << endl;
}
int main() {
  int test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
}
