#include<iostream>
#include<cstdio>
#define maxn 100001
#define int long long
using namespace std;
void read(int &x)
{
	x = 0; int f = 1; char ch = getchar();
	while(!isdigit(ch)){if(ch == '-')f = -1; ch = getchar();}
	while(isdigit(ch)){x = (x<<3) + (x<<1) + ch - '0'; ch = getchar();}
	x = x*f;
}
int T;
int a[maxn];
int n;
signed main()
{
	read(T);
	while(T--)
	{
		read(n);
		int ans = 0;
		int Max = 0;
		int Min = 0x3f3f3f3f3f3f3f3f;
		int sum = 0;
		int summ = 0;
		for(int i = 1; i <= n; i++)read(a[i]),sum += a[i];
		if(n <= 2)
		{
			cout<<0<<endl; continue;
		}
		for(int i = 1; i <= n; i++)
		{
			if(a[i] < Min)Min = a[i];
			if(a[i] > Max)Max = a[i];
		}
		summ = sum;
		summ -= Min;
		int temp = Max*(n-1)-summ;
		if(temp >= Min)
		{
			cout<<temp-Min<<endl;
		}
		else
		{
			Min -= temp;
			if(Min%(n-1) == 0)
			{
				cout<<0<<endl; continue;
			}
			cout<<(n-1)-(Min%(n-1))<<endl;	
		}
	}
	return 0;
}