#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
bool cmp(int a, int b) { return a > b; }
int main() {
  int t, n, k;
  cin >> t;
  while (t--) {
    memset(a, 0, sizeof(a));
    cin >> n >> k;
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(a, a + n, cmp);
    long long sum = 0;
    for (int i = 0; i < k + 1; i++) {
      sum += a[i];
    }
    cout << sum << endl;
  }
  return 0;
}
