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