#include #pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; #define lli long long int #define uli unsigned long long int #define INF 9999999999 #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(25) << 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 10000000 #define ALL(a) a.begin(),a.end() #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) lli gcd(lli num1, lli num2){ if(num2>num1)swap(num1,num2); if(num2==0)return num1; lli x=1,y=1; while(num1/x>0)x*=2; while(num2/y>0)y*=2; gcd(num2,(x/y*num2)^num1); } 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; } 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(){ ios::sync_with_stdio(false); cin.tie(0); lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T; cin >> N; Vec(P,lli,N,0); rep(i,0,N)cin >> P[i]; X=P[0]; rep(i,1,N)X=gcd(X,P[i]); rep(i,0,N)sum+=P[i]; num=sum; auto St=divisor(P); for(auto v:St)if(is_multiple(v.first,X))chmin(num,sum-v.second); Out(num); }