#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const long long mod = 1e9 + 7;
const long long MAXL = 1e18 + 5;
const long long eps = 1e-8;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    long long a[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    long long ma = a[n - 1], mi = 0, cnt = 0;
    for (long long i = n - 2; i >= 0; i--) {
      if (cnt == k) {
        break;
      }
      ma += a[i];
      cnt++;
    }
    cout << ma << endl;
  }
  return 0;
}
