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