#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long infl = 1LL << 60;
char buf[1000000];
string nextLine() {
  scanf("%[^\n]", buf);
  scanf("%*c");
  return string(buf);
}
string next() {
  scanf("%s", buf);
  return string(buf);
}
int nextInt() {
  int tmp;
  scanf("%d", &tmp);
  return tmp;
}
const int MAXN = 100100;
long long ar[MAXN];
long long sum[MAXN];
long long cost(int x, int num) {
  long long s = sum[x] - sum[x - num];
  return num * ar[x] - s;
}
void solve() {
  long long n, anss = 1e9, k, a, b, c, d, m;
  cin >> n >> k;
  map<long long, long long> make_pair;
  vector<long long> v(n);
  long long mn = INT_MAX, mx = INT_MIN;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    mn = min(mn, v[i]);
    mx = max(mx, v[i]);
  }
  sort(v.begin(), v.end());
  long long x = v[n - 1];
  for (long long i = n - 2; i >= 0 && k; i--) x += v[i], k--;
  cout << x << endl;
}
int main() {
  long long test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
