#include <bits/stdc++.h>
using namespace std;
int n, k;
unsigned long long solve() {
  cin >> n >> k;
  unsigned long long a[n];
  unsigned long long mx = 0;
  unsigned long long mn = 9223372036854775807LL;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mx = max(mx, a[i]);
    mn = min(mn, a[i]);
  }
  if (k == 0) {
    return mx - mn;
  }
  sort(a, a + n);
  unsigned long long out = mx;
  for (int i = 0; i < k; i++) {
    out += a[n - i - 2];
  }
  return out;
}
int main() {
  int tt;
  cin >> tt;
  while (tt--) {
    cout << solve() << endl;
  }
}
