#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int arr[maxn];
int ham(int x, int y) { return x > y; }
int main() {
  int n, z, k;
  cin >> z;
  while (z--) {
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i];
    }
    sort(arr + 1, arr + n + 1, ham);
    int x = min(n, k + 1);
    long long ans = (long long)arr[1];
    for (int i = 2; i <= x; i++) {
      ans += (long long)arr[i];
    }
    cout << ans << endl;
  }
}
