#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    int m;
    cin >> n >> m;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    for (int i = n - 2; i >= 0; i--) {
      a[n - 1] += a[i];
      m--;
      if (m == 0) break;
    }
    if (n == 1) {
      cout << 0 << endl;
    } else {
      cout << a[n - 1] << endl;
    }
  }
  return 0;
}
