unittest
{
	assert( [ "2 10", "1 100" ].parse.expand.solve == 12 );
	assert( [ "3 10", "100 1 100" ].parse.expand.solve == 23 );
	assert( [ "4 10", "1 2 3 4" ].parse.expand.solve == 10 );
}



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 nx = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nx[ 1 ], as );
}

auto solve( long x, long[] as )
{
	// 魔法をi回使うと仮定したときに何秒かかるかを計算
	auto ans = long.max;
	auto ms = as.dup;
	for( auto i = 0L; i < ms.length; i++ )
	{
		// 魔法をc回使う ⇒ as[ k - i .. k + 1 ] のどれかを捕まえる ⇒ 魔法をi-c回使う（ 0 <= c <= i ）
		auto t = 0L;
		for( auto k = 0L; k < ms.length; k++ )
		{
			if( 0 <= k - i ) ms[ k ] = min( ms[ k ], as[ k - i ] );
			else             ms[ k ] = min( ms[ k ], as[ k - i + as.length.signed ] );
			t += ms[ k ];
		}
		ans = min( ans, t + x * i );
	}
	return ans;
}
