#include #include #include #include using namespace std; #define LL long long LL a[100005]; int main() { // freopen("in.txt","r",stdin);freopen("out.txt","w",stdout); int T; scanf("%d",&T); while (T--) { int i,n,k;LL ans=0; scanf("%d%d",&n,&k); for (i=1;i<=n-1;i++) scanf("%I64d",&a[i]); sort(a+1,a+n);ans=n;n-=k-1; for (i=n-1;i>=1;i--) ans+=a[i]; printf("%I64d\n",ans); } return 0; }