import sys input = sys.stdin.readline N = int(input().rstrip('\n')) A = list(map(int, input().rstrip('\n').split())) def GCD(x,y): if x>y: x,y=y,x while x!=0: Lx=len(str(bin(x))) Ly=len(str(bin(y))) y^=x<<(Ly-Lx) if x>y: x,y=y,x return y def usable(x,g): Lx=len(str(bin(x))) Lg=len(str(bin(g))) while Lx>=Lg and x!=0: x^=g<<(Lx-Lg) Lx=len(str(bin(x))) return x==0 S=sum(A) M=max(A) mi=[0] for i in range(M): mi.append(0) G=0 for x in A: G=GCD(G,x) j=1 while j*j<=x: if x%j==0: mi[j]+=x-x//j if j*j!=x: mi[x//j]+=x-j j+=1 X=S for i in range(2,M+1): if(usable(i,G)): X=min(X,S-mi[i]) print(X)