#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, k;
    cin >> n >> k;
    vector<long long int> v;
    for (int j = 0; j < n; j++) {
      long long int a;
      cin >> a;
      v.push_back(a);
    }
    sort(v.begin(), v.end());
    long long int max = v[v.size() - 1];
    for (int j = 1; j <= k; j++) {
      int ind = v.size() - 1 - j;
      if (ind < 0) break;
      max += v[ind];
    }
    cout << max << endl;
  }
}
