#include #include #include #include #define M 100005 #define Tl tree[l] #define Tr tree[r] #define Tp tree[p] #define lson l,mid,p<<1 #define rson mid+1,r,p<<1|1 #define rep(i,s,t) for(int i=s;i<=t;++i) #define rrep(i,s,t) for(int i=s;i>=t;--i) bool mark[5005]; using namespace std; inline void Rd(int &res){ char c;res=0; while(c=getchar(),c<48); do res=res*10+(c&15); while(c=getchar(),c>47); } int n,m,k; int A[M]; int main(){ int T; scanf("%d",&T); while(T--&&scanf("%d %d",&n,&k)){ rep(i,0,n-2)Rd(A[i]); sort(A,A+n-1); long long sum=n; rep(i,0,n-k-1)sum+=A[i]; printf("%lld\n",sum); } return 0; }