#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
inline void bugp(const pair<T, V> &x) {
  cerr << '{' << x.first << ", " << x.second << '}' << endl;
}
template <typename T, typename U, typename V>
inline void bugpp(const pair<T, pair<U, V> > &x) {
  cerr << '{' << x.first << ", {" << x.second.first << ", " << x.second.second
       << "}}" << endl;
}
int n, k;
int arr[200002];
void input() {
  cin >> n >> k;
  for (int i = 1, _n = (n); i <= _n; ++i) cin >> arr[i];
}
void solve() {
  sort(arr + 1, arr + n + 1);
  long long ans = 0;
  for (int i = (n), _b = (n - k); i >= _b; --i) ans += arr[i];
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int test;
  cin >> test;
  while (test--) {
    input();
    solve();
  }
  return 0;
}
