#include <bits/stdc++.h>
#define union Union
#define rank rank228
#define tm tm228
#define hash hash228
#define matr vector < vector < int > >
#define int long long
#define pii pair < int, int >
#define papa pair < Node*, Node* >
#define all(v) v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define PI 3.14159265358979323846
#define ff first
#define ss second
//#define mp make_pair

using namespace std;

const int inf = 1e18, maxn = 1e6 + 100, mod = 1e9 + 7;

int mx[2][maxn];

int a[maxn];

void solve(){
    int n, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    mx[0][0] = 0;
    mx[1][n] = 0;
    for (int i = 0; i < n; ++i)
    {
        mx[0][i + 1] = max(mx[0][i], a[i]);
    }
    for (int i = n - 1; i >= 0; --i)
    {
        sum += a[i];
        mx[1][i] = max(mx[1][i + 1], a[i]);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        int mm = max(mx[0][i], mx[1][i + 1]);
        int tmp = mm * (n - 1);
        if (tmp > sum)
        {
            ans = max(ans, tmp - sum);
        }
        if (tmp < sum)
        {
            int x = tmp - sum;
            x %= (n - 1);
            if (x < 0)
                x+=(n-1);
            ans = max(x, ans);
        }
    }
    cout << ans;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    srand(100);
    cout << fixed << setprecision(10);
    int t = 1;
    #ifdef LOCAL
        freopen("task.in", "r", stdin);
    #endif
    cin >> t;
    while (t--)
    {
        solve();
        cout << endl;
    }
}
