#include using namespace std; #define lli long long int #define uli unsigned long long int #define INF 999999999999999999 #define rep(i,m,n) for(lli i = m;i < n;i++) #define rrep(i,m,n) for(lli i=m-1;i>=n;i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(),N.end()),N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(),n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(30) << S << endl #define Vec(K,L,N,S) vector K(N,S) #define DV(K,L,N,M,S) vector> K(N,vector(M,S)) #define TV(K,L,N,M,R,S) vector>> K(N,vector>(M,vector(R,S))) #define pint pair #define paf(L,R) pair #define mod 1000000007 #define MAX 5100000 #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) map divisor(vectorHP){ mapres; for(auto N:HP){ for(lli i=1;i*i<=N;i++){ if(N%i==0){ res[i]+=N-N/i; if(i!=N/i)res[N/i]+=N-N/(N/i); } } } return res; } lli f2_gcd(bitset<20> A,bitset<20> B) { int i; for(i=20;i>=0;i--) { if(A[i]==1 && B[i]==1) { B^=A; break; } if(A[i]==1) break; if(B[i]==1) { swap(A,B); break; } } // A>B while(1){ int x; for(x=i-1;x>=0;x--)if(B[x]) break; if(x<0) break; while(i>=x) { if(A[i]) A^=B<<(i-x); i--; } i=x; swap(A,B); } lli x=0; rep(i,0,20)if(A[i]==1)x+=pow(2,i); return x; } bool is_multiple(int x,int g){ int Lx=32-__builtin_clz(x),Lg=32-__builtin_clz(g); while(Lx>=Lg&&x!=0){ x^=g<<(Lx-Lg); Lx=32-__builtin_clz(x); } return x==0; } int main(){ lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T; assert(cin >> N); assert(N>100000||2>N); Y=0; Vec(HP,lli,N,0); rep(i,0,N){ assert(cin >> HP[i]); assert(HP[i]>400000); } X=f2_gcd(HP[0],HP[1]); rep(i,2,N)X=f2_gcd(HP[i],X); rep(i,0,N){ chmax(Y,HP[i]); sum+=HP[i]; } num=sum; auto St=divisor(HP); for(auto v:St)if(is_multiple(v.first,X))num=min(num,sum-v.second); Out(num); }