#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
inline int add(int a, int b) {
  int ret = ((long long int)a + b) % mod;
  if (ret < 0) ret += mod;
  return ret;
}
inline int mul(int a, int b) {
  int ret = ((long long int)a * b) % mod;
  if (ret < 0) ret += mod;
  return ret;
}
template <typename... Args>
inline int add(int a, Args... args) {
  return add(a, add(args...));
}
template <typename... Args>
inline int mul(int a, Args... args) {
  return mul(a, mul(args...));
}
inline int addm(int a, int b, int MOD) {
  int ret = ((long long int)a + b) % MOD;
  if (ret < 0) ret += MOD;
  return ret;
}
inline int mulm(int a, int b, int MOD) {
  int ret = ((long long int)a * b) % MOD;
  if (ret < 0) ret += MOD;
  return ret;
}
inline int addm(int a, int b, int c, int MOD) {
  return addm(a, addm(b, c, MOD), MOD);
}
inline int mulm(int a, int b, int c, int MOD) {
  return mulm(a, mulm(b, c, MOD), MOD);
}
template <typename T>
void show2d(const vector<vector<T>>& adj) {
  for (auto x : adj) {
    for (auto y : x) {
      cout << y << " ";
    }
    cout << "\n";
  }
}
long long int modexp(long long int a, long long int b, long long int mod) {
  long long int x = 1;
  while (b) {
    if (b & 1) x = ((x % mod) * (a % mod)) % mod;
    a = ((a % mod) * (a % mod)) % mod;
    b = b / 2;
  }
  return x;
}
bool ispalindrome(long long int n) {
  long long int rev = 0, n1 = n;
  while (n1 > 0) {
    rev = rev * 10 + n1 % 10;
    n1 /= 10;
  }
  return (n == rev);
}
void rf() {}
void solve() {
  int n, k;
  cin >> n >> k;
  long long int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + n, greater<long long int>());
  long long int sum = 0;
  for (int i = 0; i <= k; ++i) sum += a[i];
  cerr << "sum"
       << ": " << sum << endl;
  cout << sum << "\n";
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
