#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-Ofast")
using namespace std;
const long long MAX = 3e5 + 5;
const long long MAAX = 1e18;
const long long mod = 1e9 + 7;
long long a[MAX];
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    for (long long i = n - 2; i > n - 2 - k; i--) {
      a[n - 1] += a[i];
      a[i] = 0;
    }
    cout << a[n - 1] << endl;
  }
  return 0;
}
