#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    long long arr[n];
    for (long long i = 0; i < n; i++) cin >> arr[i];
    ;
    sort(arr, arr + n);
    if (n == 1) {
      cout << 0 << '\n';
      continue;
    }
    int i = n - 2;
    while (i >= 0 && k--) {
      arr[n - 1] += arr[i];
      arr[i] = 0;
      i--;
    }
    cout << arr[n - 1] << '\n';
  }
}
