#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<long long> v;
    for (long long i = 0; i < n; i++) {
      long long a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    long long ans = 0;
    for (long long i = 0; i <= k; i++) {
      ans += v[n - i - 1];
      v.pop_back();
    }
    cout << ans << endl;
  }
}
