#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 7;
int n, t, k, arr[N];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
    }
    sort(arr + 1, arr + n + 1);
    long long res = 0;
    for (int i = n; i >= n - k; i--) {
      res += arr[i];
    }
    cout << res << endl;
  }
  return 0;
}
