#include #include #include #include #include #include #define pb push_back #define LL long long using namespace std; const int N = 100010; int a[N]; int main() { int T; scanf("%d", &T); while (T--) { int n, k; scanf("%d%d", &n, &k); LL sum = n; for (int i = 1; i <= n - 1; ++i) { scanf("%d", &a[i]); sum += (LL)a[i]; } if (k >= n) { printf("%d\n", n); continue; } sort(a + 1, a + n); for (int i = n - 1, j = 0; i >= 1 && j < k - 1; --i, ++j) { sum -= (LL)a[i]; } printf("%I64d\n", sum); } return 0; }