#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { long long data[100005]; int n, m; int t; cin >> t; while (t--) { cin >> n >> m; n--; m--; long long cnt = 0; for (int i = 0; i < n; i++) { scanf("%I64d", &data[i]); data[i]++; cnt += data[i]; } cnt++; sort(data, data + n); for (int i = n - 1; i >= 0 && n - i <= m; i--) { cnt -= data[i]; cnt += 1; } cout << cnt << "\n"; } }