#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int maxn = 1e5+100; const ll inf = 0x3f3f3f3f; int n, k; int a[maxn], d[maxn]; int main() { int T; cin>>T; while(T--) { scanf("%d%d",&n,&k); for(int i = 1; i < n; i++){ scanf("%d",&a[i]); } sort(a+1,a+n); a[n] = inf; int temp; if(k>n){ temp = 0; }else { temp = n-k+1; } ll ans = 0; for(int i = 1; i < temp; i++){ ans += a[i]+1; } printf("%I64d\n",ans+min(n,k)); } return 0; }