#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, k;
    vector<int> v;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      v.push_back(x);
    }
    sort(v.begin(), v.end());
    long long sum = 0;
    int count = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (count <= k) {
        sum += v[i];
        count++;
      }
    }
    cout << sum << "\n";
  }
  return 0;
}
