import std.algorithm;
import std.conv;
import std.stdio;
import std.string;
import std.math;

void main()
{
	auto n = readln.strip.to!( int );
	auto as = readln.split.to!( long[] );
	writeln( solve( as ) );
}

auto solve( in long[] as )
{
	auto ms = as.dup;
	auto mi = size_t.init;
	auto ma = size_t.init;
	
	while( true )
	{
		auto eq = true;
		
		foreach( i, m; ms )
		{
			if( ms[ mi ] != m ) eq = false;
			if( m < ms[ mi ] ) mi = i;
			if( ms[ ma ] < m ) ma = i;
		}
		
		if( eq ) break;
		
		auto mm = lcm( ms[ mi ], ms[ ma ] );
		ms[ mi ] = mm;
		ms[ ma ] = mm;
	}
	
	auto m = ms[ 0 ] - 1;
	
	return as.map!( ( a ) => m % a ).sum;
}

auto lcm( in long a, in long b )
{
	real ma = a;
	real mb = b;
	
	while( ma != mb )
	{
		if( ma < mb ) ma = a * ceil( mb / a );
		else          mb = b * ceil( ma / b );
	}
	
	return cast( long ) ma;
}
