#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 66;
int n, arr[N], k;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n >> k;
    for (int i = 1; i <= n; ++i) cin >> arr[i];
    sort(arr + 1, arr + 1 + n);
    long long ans = arr[n];
    for (int i = 0, j = n - 1; i < k; ++i, --j) ans += arr[j];
    cout << ans << "\n";
  }
  return 0;
}
