#include <bits/stdc++.h>
const long long INF = 1e18;
const long long mINF = (-1) * INF;
const long long inf = 1e5 + 5;
using namespace std;
long long power(long long a, long long b) {
  long long result = 1;
  while (b) {
    if (b % 2) result = (result * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return result;
}
map<int, vector<int>> graph;
vector<int> visited(inf, 0);
vector<int> dist(inf);
void dfs(int node, int color) {
  visited[node] = 1;
  for (auto child : graph[node]) {
    if (visited[child] == 0) {
      dist[child] = 1 - color;
      dfs(child, 1 - color);
    }
  }
}
void solve() {
  int n, i, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (auto &x : v) {
    cin >> x;
  }
  sort(v.begin(), v.end());
  if (n == 1) {
    cout << 0 << endl;
    return;
  }
  i = n - 2;
  long long ans = v[n - 1];
  while (k-- && i >= 0) {
    ans += v[i];
    i--;
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
