unittest
{
	assert( [ "3", "2 3 4" ].parse.expand.solve == 13 );
	assert( [ "5", "12 12 12 12 12" ].parse.expand.solve == 5 );
	assert( [ "3", "1000000 999999 999998" ].parse.expand.solve == 996989508 );
}



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

auto solve( long[] as )
{
	// asの最小公倍数を素因数分解で計算
	auto apss = new long[ long ][ as.length ];
	long[ long ] mps;
	{
		auto ps = as.reduce!max.primes;
		foreach( ref aps, a; lockstep( apss, as ) )
		{
			foreach( g; primefactorize( a, ps ).group )
			{
				aps[ g[ 0 ] ] = g[ 1 ];
				if( g[ 0 ] !in mps ) mps[ g[ 0 ] ] = g[ 1 ];
				else                 mps[ g[ 0 ] ] = max( mps[ g[ 0 ] ], g[ 1 ] );
			}
		}
	}
	
	// bsの合計を計算
	auto ans = 0L;
	foreach( aps; apss )
	{
		auto b = 1L;
		foreach( p, n; mps )
		{
			if(      p !in aps    ) b = b.mulMod( p.powMod( n ) );
			else if( aps[ p ] < n ) b = b.mulMod( p.powMod( n - aps[ p ] ) );
		}
		ans = ans.addMod( b );
	}
	return ans;
}

// 素数列
auto primes( long x )
{
	Appender!( long[] ) ps;
	if( x < 2 ) return ps.data;
	
	auto cs = new bool[]( x + 1 );
	ps ~= 2L;
	for( auto i = 3L; i * i < cs.length; i += 2 )
	{
		if( cs[ i ] ) continue;
		for( auto j = i; i * j < cs.length; j++ )
		{
			cs[ i * j ] = true;
		}
	}
	for( auto i = 3L; i < cs.length; i += 2 )
	{
		if( !cs[ i ] ) ps ~= i;
	}
	return ps.data;
}

// 素因数分解
auto primefactorize( long x, long[] ps )
{
	Appender!( long[] ) fs;
	if( x < 2 ) return fs.data;
	
	auto s = ( cast( long ) x ^^ 0.5L ) + 1;
	foreach( p; ps )
	{
		if( s < p ) break;
		while( x % p == 0 )
		{
			x /= p;
			fs ~= p;
		}
		if( x < 2 ) break;
	}
	if( 2 <= x ) fs ~= x;
	return fs.data;
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}
