#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize "trapv"
template <typename T>
void pop_front(std::vector<T> &v) {
  if (v.size() > 0) {
    v.erase(v.begin());
  }
}
template <typename R>
void pop_back(std::vector<R> &v) {
  if (v.size() > 0) {
    v.erase(v.begin() + v.size() - 1);
  }
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
bool isPerfectSquare(long double x) {
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
}
bool isprime(long long int n) {
  if (n <= 1) return false;
  for (long long int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
void prime_factors(long long int n) {
  for (long long int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      long long int count = 0;
      while (n % i == 0) {
        count++;
        n = n / i;
      }
      cout << i << " "
           << "^"
           << " " << count << "\n";
    }
  }
  if (n > 1)
    cout << n << " "
         << "^"
         << " " << 1 << "\n";
}
vector<long long int> divisors(long long int n) {
  vector<long long int> v;
  for (long long int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if ((n / i) != i) v.push_back(n / i);
    }
  }
  return v;
}
long long int power(long long int a, long long int n, long long int m) {
  long long int res = 1;
  while (n) {
    if (n % 2)
      res = (res * a) % m, n--;
    else
      a = (a * a) % m, n /= 2;
  }
  return res;
}
long long int ts(long long int arr[], int l, int r, int x) {
  while (l <= r) {
    long long int mid1 = l + (r - l) / 3;
    long long int mid2 = r - (r - l) / 3;
    if (arr[mid1] == x || arr[mid2] == x) return 1;
    if (x < arr[mid1])
      r = mid1 - 1;
    else if (x > arr[mid2])
      l = mid2 + 1;
    else {
      l = mid1 + 1;
      r = mid2 - 1;
    }
  }
  return -1;
}
long long int modulo_inverse(long long int a, long long int m) {
  long long int res = power(a, m - 2, m);
  return res;
}
long long int Extended_gcd(long long int a, long long int b, long long int &x,
                           long long int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  long long int x1, y1;
  long long int g = Extended_gcd(b, a % b, x1, y1);
  x = y1;
  y = x1 - (a / b) * y1;
  return g;
}
vector<long long int> count_freq(string &str, string &substr) {
  vector<long long int> pos;
  size_t found = str.find(substr, 0);
  while (found != string::npos) {
    pos.push_back(found);
    found = str.find(substr, found + 1);
  }
  return pos;
}
int main() {
  auto start = chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, k;
    cin >> n >> k;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    sort(a, a + n);
    long long int sum = a[n - 1];
    if (k == 0) {
      cout << a[n - 1] - a[0] << endl;
    } else {
      for (int i = n - 2; i >= 0; i--) {
        sum += a[i];
        k--;
        if (k == 0) {
          break;
        }
      }
      cout << sum << endl;
    }
  }
  auto finish = chrono::high_resolution_clock::now();
  cerr << "Time elapsed: "
       << (chrono::duration<long double>(finish - start)).count() << "s\n";
  return 0;
}
