#include <bits/stdc++.h>
using namespace std;
long long int bucks[200006] = {};
int main() {
  long long int t;
  cin >> t;
  long long int l = 0;
  while (l < t) {
    long long int n, k;
    cin >> n >> k;
    for (long long int i = 0; i < n; i++) {
      cin >> bucks[i];
    }
    sort(bucks, bucks + n);
    long long int sum = 0;
    for (long long int i = n - 1; i >= n - 1 - k; i--) {
      sum += bucks[i];
    }
    cout << sum << endl;
    l++;
  }
  return 0;
}
