#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 //#define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 const double EPS = 1e-10; using ll = long long; using Pi = pair; using Pl = pair; ll GCD(ll a, ll b) { if (b == 0) return a; else return GCD(b, a % b); } int main(){ int N; cin >> N; vector A(N); rep(i,N) cin >> A[i]; sort(A.begin(),A.end()); vector sum(N+1); for(int i = N; i >= 1; i--){ sum[i-1] = sum[i] +A[i-1]; } int k = 0; ll a = LINF; int ans = 0; for(int i = N-1; i >= 0; i--){ k = GCD(k,A[i]); if(a > sum[i]/k+sum[0]-sum[i-1]){ a = sum[i]/k+sum[0]-sum[i-1]; ans = k; } //cout << a << endl; } rep(i,N){ if(A[i] % ans == 0) A[i] /= ans; } ll m = 0; rep(i,N){ m += A[i]; } cout << m << endl; }