unittest
{
	assert( [ "2", "1 4" ].parse.expand.solve == 5 );
	assert( [ "7", "14 14 2 13 56 2 37" ].parse.expand.solve == 2354 );
}



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

auto solve( long[] xs )
{
	auto ans = long.max;
	foreach( p; 1L .. 101L )
	{
		auto t = 0L;
		foreach( x; xs )
		{
			t += ( x - p ) ^^ 2;
		}
		ans = min( ans, t );
	}
	return ans;
}
