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