#include using namespace std; using ll = long long; constexpr int MAXV = 100000; constexpr int LOG_MAXV = 17; ll cnt[MAXV + 1]; bool exists[MAXV + 1], 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]; } } for (int i = 0; i < n; i++) { int val = a[i]; do { exists[val] = true; val <<= 1; } while (val <= maxa); } vector v; for (int i = 1; i <= maxa; i++) { if (exists[i]) v.push_back(i); } int rank = 0; for (int col = 0; col < LOG_MAXV; ++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; } for (int i = 1; i < (1 << rank); i++) { int val = 0; for (int j = 0; j < rank; j++) { if (i & (1 << j)) 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; }