unittest
{
	assert( [ "4", "3 3 3 3" ].parse.expand.solve == 0 );
	assert( [ "3", "1 0 3" ].parse.expand.solve == 1 );
	assert( [ "2", "2 2" ].parse.expand.solve == 2 );
	assert( [ "7", "27 0 0 0 0 0 0" ].parse.expand.solve == 3 );
	assert( [ "10", "1000 193 256 777 0 1 1192 1234567891011 48 425" ].parse.expand.solve == 1234567894848 );
	
	assert( [ "50", ( 10L ^^ 16 + 1000 ).to!string.repeat( 50 ).join( " " ) ].array.parse.expand.solve == 500000000000047550 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( n, as );
}

auto solve( long n, long[] as )
{
	auto ans = 0L;
	while( n <= as.reduce!max )
	{
		// n引く
		auto t = 0L;
		foreach( ref a; as )
		{
			auto c = ( a + t ) / n;		// ceil( ( ( a + t ) - ( n - 1 ) ) / n )
			a -= c * ( n + 1 );			// 余分に1引いておくことで、後ろの足す処理を簡単にする
			t += c;
		}
		
		// n引いた回数だけ全体に1足す
		as[] += t;
		ans += t;
	}
	return ans;
}
