#include <bits/stdc++.h>
using namespace std;

#define int long long
const int N = 1e5 + 100;
int a[N];
signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE 
	freopen("E:\\in.txt", "r", stdin);
#endif
	int T; cin >> T;
	while (T--) {
		int n; cin >> n;
		int res = 0;
		int mx = 0, mn = 1e18;
		int se = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			mx = max(mx, a[i]);
			mn = min(mn, a[i]);
		}

		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += mx - a[i];
		}
		// 不选最大值 
		for (int i = 0; i < n; i++) {
			if (a[i] == mx) continue;
			int x = sum - (mx - a[i]);
			if (a[i] >= x) {
				int left = a[i] - x;
				left = left % (n - 1);
				int tmp1;
				if (left) {
					tmp1 = n - 1 - left;
				}
				else {
					tmp1 = 0;
				}
				res = max(res, tmp1);
			}
			else {
				res = max(res, x - a[i]);
			}
		}
		int tmp = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] == mx) tmp++;
		}
		if (tmp == 1) {
			for (int i = 0; i < n; i++) {
				if (a[i] != mx) {
					se = max(se, a[i]);
				}
			}
		}
		else {
			se = mx;
		}
		// 选最大值 其它先变次大值 
		int d = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] != mx) {
				d += se - a[i];
			}
		}
		if (mx >= d) {
			int left = mx - d;
			left = left % (n - 1);
			int tmp2;
			if (left) {
				tmp2 = n - 1 - left;
			}
			else {
				tmp2 = 0;
			}
			res = max(res, tmp2);
		}
		else {
			res = max(res, d - mx);
		}
		cout << res << '\n';
	}
}