#include <bits/stdc++.h>
using namespace std;
void sol() {
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long &el : a) {
    cin >> el;
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  for (long long i = 1; i <= k; i++) {
    a[0] += a[i];
    a[i] = 0;
  }
  cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end())
       << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  long long t = 1;
  cin >> t;
  while (t--) {
    sol();
  }
}
