import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto N = readln.split[0].to!int;
	auto A = readln.split.to!(int[]);
	
	auto Amin = A.reduce!"min(a,b)";
	auto gcd = 1;
	_gcd: foreach_reverse(d; 1 .. Amin+1) {
		foreach (a; A) { if (a%d != 0) continue _gcd; }
		gcd = d;
	}
	writeln(A.sum - N*gcd);
}