#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n, k;
    cin >> n >> k;
    vector<long long int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    long long int curr = v[n - 1];
    for (int i = n - 2; i >= 0; i--) {
      if (k == 0) break;
      curr += v[i];
      k--;
    }
    cout << curr << endl;
  }
}
