#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n, k, i, j;
    cin >> n >> k;
    long long int a[n], sum = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    for (j = n - 1, i = 0; i <= k; i++, j--) {
      sum = sum + a[j];
    }
    cout << sum << endl;
  }
}
