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