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 Lx=len(bin(x)) Ly=len(bin(y)) if x!=0: return GCD(x,y^(x<<(Ly-Lx))) else: return y def usable(x,g): Lx=len(bin(x)) Lg=len(bin(g)) while Lx>=Lg and x!=0: x^=g<<(Lx-Lg) Lx=len(bin(x)) return x==0 S=sum(A) M=max(A) mi=[0] for i in range(M): mi.append(0) div = [[]]*(M+1) for i in range(1,M+1): j=i while j<=M: div[j].append(i) j+=i 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)