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