#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define getmid(l,r) ((l) + ((r) - (l)) / 2) #define MEM(a,b) memset(a,b,sizeof(a)) #define MP(a,b) make_pair(a,b) #define PB push_back typedef long long ll; typedef pair pii; const double eps = 1e-8; const int INF = (1 << 30) - 1; const int MAXN = 100010; int T,n,k; int D[MAXN]; int main(){ scanf("%d",&T); while(T--){ scanf("%d%d",&n,&k); for(int i = 1; i < n; ++i){ scanf("%d",&D[i]); } sort(D + 1,D + n); k--; ll ans = 0; for(int i = 1; i <= n - 1 - k; ++i){ ans += D[i]; } ans += n; printf("%I64d\n",ans); } return 0; }