#include <bits/stdc++.h>
using namespace std;
const int ma = 2e5 + 7;
long long n, m, k, num[ma];
string s;
int main() {
  int t;
  scanf("%d", &t);
  long long a, b, c;
  int temp;
  long long ans;
  while (t--) {
    scanf("%I64d%I64d", &n, &k);
    a = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%I64d", num + i);
    }
    sort(num + 1, num + 1 + n);
    c = n - 1;
    while (k && c >= 1) {
      num[n] += (num[c]), num[c] = 0, c--;
      k--;
    }
    ans = num[n] - 0;
    printf("%I64d\n", ans);
  }
  return 0;
}
