#include #include #include #include using namespace std; typedef long long ll; int gcd(int x, int y){ if(x < y) swap(x, y); if(y == 0) return x; int cp = y; while((int)(log2(x)) > (int)(log2(y))) y <<= 1; return gcd(cp, x^y); } int main(){ int n; cin >> n; vector v(n); for(int i = 0; i < n; i++) cin >> v[i]; ll ans = accumulate(v.begin(), v.end(), 0ll); vector d(100001); for(int i = 0; i < n; i++){ ll x = v[i]; for(ll i = 1; i*i <= x; i++){ if(x%i) continue; d[i] += x-x/i; if(i*i != x) d[x/i] += x-i; } } int g = 0; for(int i = 0; i < n; i++) g = gcd(g, v[i]); int k = 0; for(int i = 0; i < 18; i++) if((g>>i)&1) k = i; ll sub = 0; for(int i = 1; i <= 100000; i++){ int make = 0; for(int j = 17; j >= k; j--) if(((i>>j)&1)==1 && ((make>>j)&1)==0) make ^= g<<(j-k); if(make==i) sub = max(sub, d[i]); } cout << ans-sub << endl; return 0; }