#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int t;
long long a[MAXN];
int main() {
  cin >> t;
  while (t--) {
    int n, k;
    cin >> n >> k;
    for (int i = (1); i <= (n); ++i) scanf("%lld", a + i);
    sort(a + 1, a + 1 + n, greater<int>());
    long long ans = 0;
    for (int i = (1); i <= (min(k + 1, n)); ++i) ans += a[i];
    printf("%lld\n", ans);
  }
  return 0;
}
