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