#include <bits/stdc++.h>
using namespace std;
int main(){
	int T; cin >> T; 
	long long A[114514]; 
	while(T--){
		int N; cin >> N; 
		long long S = 0; 
		for(int i = 0; i < N; i++){
			cin >> A[i]; S += A[i]; 
		}
		sort(A, A+N, greater<long long>()); 
		if(S == 0) cout << 0 << "\n"; 
		else cout << max({A[1] * (N-1) - S, A[0] * (N-1) - S, N-2 - (S-1) % (N-1)}) << "\n"; 
	}
}