#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)7 + (long long)1e9;
const long long N = 2000005;
const double PI = 4 * atan(1);
const double eps = 1e-10;
const long long oo = 1e10;
const int K = 26;
int t;
int n, k;
long long a[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    for (int i = n - 2; i >= 0, k != 0; i--, k--) {
      a[n - 1] += a[i];
      a[i] = 0;
    }
    cout << a[n - 1] << endl;
  }
  return 0;
}
