#include <bits/stdc++.h>
using namespace std;
int INF = INT_MAX;
long long mod = 1000000007;
void solve() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = n - 2; i >= 0; i--) {
    if (k <= 0) break;
    a[n - 1] += a[i];
    a[i] = 0;
    k--;
  }
  long long mini = a[n - 1];
  for (int i = 0; i < n; i++) mini = min(mini, a[i]);
  cout << a[n - 1] - mini << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) solve();
}
