#include <bits/stdc++.h>
const long long int LL_INF = 0x3f3f3f3f3f3f;
const long long int MOD = 1073741824;
using namespace std;
int T;
int n, m, k;
long long int inp;
string arr[1000005];
set<int> st;
vector<long long int> v;
map<int, int> mp;
string str;
void gen() {}
void solve() {
  v.clear();
  scanf("%d", &n);
  scanf("%d", &k);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", &inp);
    v.push_back(inp);
  }
  sort(v.begin(), v.end());
  ;
  for (int i = v.size() - 2; i >= 0 && k; --i) {
    k--;
    if (v[i]) {
      v[v.size() - 1] += v[i];
      v[i] = 0;
    }
  }
  printf("%lld\n", v[v.size() - 1]);
}
int main() {
  scanf("%d", &T);
  for (int i = 0; i < T; ++i) solve();
  printf("\n");
  return 0;
}
