#include using namespace std; using ll = long long; constexpr int MAXV = 100000; constexpr int LOG_MAXV = 30; ll cnt[MAXV + 1]; bool ok[MAXV + 1]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector a(n); ll sum = 0; int maxa = 0; for (int i = 0; i < n; i++) { cin >> a[i]; maxa = max(maxa, a[i]); cnt[a[i]] += a[i]; sum += a[i]; } for (int i = 1; i <= maxa; i++) { for (int j = i; (j += i) <= maxa; ) { cnt[i] += cnt[j]; } } vector v; for (int i = 0; i < n; i++) { int val = a[i]; do { v.push_back(val); val <<= 1; } while (val <= 5e8); } /* vector v; for (int i = 1; i <= MAXV; i++) { if (exists[i]) v.push_back(i); }*/ int rank = 0; for (int col = LOG_MAXV - 1; col >= 0; --col) { int pivot = -1; for (int row = rank; row < v.size(); ++row) { if (v[row] & (1 << col)) { pivot = row; break; } } if (pivot == -1) continue; swap(v[pivot], v[rank]); for (int row = 0; row < v.size(); ++row) { if (row != rank && (v[row] & (1 << col))) { v[row] ^= v[rank]; } } ++rank; } int geta = 0; while (geta < rank) { if (v[geta] <= maxa) break; geta++; } for (int i = 1; i < (1 << (rank - geta)); i++) { int val = 0; for (int j = geta; j < rank; j++) { if (i & (1 << (j - geta))) val ^= v[j]; } if (val <= maxa) ok[val] = true; } ll ans = sum; for (int i = 1; i <= maxa; i++) { if (!ok[i]) continue; ans = min(ans, sum - cnt[i] + cnt[i] / i); } cout << ans << "\n"; return 0; }