#include #include #include using namespace std; const int N = 1e5 + 5; int n, k, a[N]; int main() { int t; scanf("%d", &t); while (t--) { scanf("%d %d", &n, &k); for (int i = 1; i < n; i++) scanf("%d", a + i); long long res = 0; sort(a + 1, a + n); k = min(k, n); for (int i = 1; i <= n - k; i++) res += a[i] + 1; res += k; cout << res << endl; } }