unittest
{
	assert( [ "5 2" ].parse.expand.solve == 18 );
	assert( [ "3 -1" ].parse.expand.solve == 0 );
	assert( [ "30 -50" ].parse.expand.solve == -1044 );
}



import std.algorithm;
import std.conv;
import std.math;
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 nl = input.front.split.to!( long[] );
	return tuple( nl[ 0 ], nl[ 1 ] );
}

auto solve( long n, long l )
{
	auto ts = new long[ n ];
	foreach( i, ref t; ts )
	{
		t = l + i.signed;
	}
	auto tm = ts.sum;
	
	auto ans = long.max;
	foreach( t; ts )
	{
		auto tt = tm - t;
		if( ( tm - tt ).abs < ( tm - ans ).abs ) ans = tt;
	}
	return ans;
}
