#include using namespace std; using ll = long long; #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) #define repe(i, l, r) for (int i = (l); i < (r); i++) #define reper(i, l, r) for (int i = (r) - 1; i >= (l); i--) #define repi(i, l, r) for (int i = (l); i <= (r); i++) #define repir(i, l, r) for (int i = (r); i >= (l); i--) #define range(a) a.begin(), a.end() void initio() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } int main() { initio(); int N; cin >> N; vector A(N); rep(i, N) cin >> A[i]; vector kitei; for (ll x : A) { for (int i = 0; i < 17; i++) { ll y = x << i; for (ll z : kitei) y = min(y, y ^ z); if (y != 0) { kitei.push_back(y); } } } auto can = [&](ll x) { for (ll z : kitei) x = min(x, x ^ z); return x == 0; }; vector sum(100001); for (ll x : A) sum[x] += x; ll ans = LLONG_MAX; for (int i = 1; i <= 100000; i++) { for (int j = i * 2; j <= 100000; j += i) { sum[i] += sum[j]; } } ll total = 0; for (ll x : A) total += x; for (int i = 1; i <= 100000; i++) { if (can(i)) { ans = min(ans, total - sum[i] + sum[i] / i); } } cout << ans << endl; }