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