unittest
{
	assert( [ "2" ].solve == 14 );
	assert( [ "10" ].solve == 1110 );
}



import std.conv;
import std.range;
import std.stdio;

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

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	return n + n ^^ 2 + n ^^ 3;
}
