#include <bits/stdc++.h>
#define int int64_t
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;

void solve() {
    int n, m; cin >> n >> m;
    multiset<int> a;

    int sum = 0;

    for (int i = 0; i < n; i++) {
        int x = 0;
        sum += x;
        a.insert(x);
    }

    for (int i = 0; i < m; i++) {
        int x; cin >> x;
        int cur = *a.begin();
        a.erase(a.begin());

        sum -= cur;
        cur = x - cur;

        sum += cur;

        a.insert(cur);
    }

    cout << sum;
}

signed main() {
    int tt; cin >> tt;


    while (tt--)
        solve(), cout << '\n';
}