/* ********************************* Author :clogos Created Time :2016/07/30 19:35:40 File Name :B.cpp ********************************** */ #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int inf = 0x3f3f3f3f; const int N = 100000 + 10; priority_queue, less > que; int main() { //freopen("out", "w", stdout); //freopen("in", "r", stdin); int cases; scanf("%d", &cases); while(cases--) { int n, k; scanf("%d%d", &n, &k); long long ans = n; while(!que.empty()) que.pop(); for(int i = 1; i < n; ++i) { int x; scanf("%d", &x); ans += x; que.push(x); } k -= 1; for(int i = 0; i < k; ++i) { ans -= que.top(); que.pop(); if(que.empty()) break; } cout << ans << endl; } return 0; }