#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
//#define int ll
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int N = 2e5 + 10;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int &x : a) cin >> x;
    int x1 = *min_element(all(a));
    int x2 = *max_element(all(a));
    reverse(all(a));
    ll ans = 0;
    int sv = n, cx1 = 0;
    for(int x : a) {
        if(x == x2) {
            if(sv > 0) {
                --sv;
                ans += x2;
            } else {
                if(cx1 > 0) {
                    --cx1;
                    ans -= 2 * x1;
                    ++sv;
                    ans += x2;
                } else {
                    ans -= x2;
                    ++sv;
                }
            }
        } else {
            if(sv > 0) {
                ++cx1;
                --sv;
                ans += x1;
            } else {
                ans -= x1;
                ++sv;
            }
        }
    }
    cout << ans << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    auto start = clock();
#endif
    int ttt = 1;
    cin >> ttt;
    while(ttt--) {
        solve();
    }
#ifdef LOCAL
    auto end = clock();
    cerr << "TIME: " << (end - start) << "ms" << '\n';
#endif
}