#include using namespace std; vector dv[100010]; long long sum[100010]; void calc_div() { for (int i = 2; i <= 100000; i++) { for (int j = i; j <= 100000; j += i) { dv[j].emplace_back(i); } } } void gj(vector &v) { int pv = 0; int n = v.size(); for (int k = 16; k >= 0; k--) { for (int i = pv; i < n; i++) { if (v[i] & (1 << k)) { swap(v[pv], v[i]); break; } } if (v[pv] & (1 << k)) { for (int i = 0; i < n; i++) { if (i == pv) continue; if (v[i] & (1 << k)) { v[i] ^= v[pv]; } } pv++; } if (pv == n) break; } } int main() { calc_div(); int n; cin >> n; long long all = 0; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; all += a[i]; for (auto &d: dv[a[i]]) sum[d] -= a[i] - a[i] / d; } for (int i = 0; i <= 100000; i++) sum[i] += all; set s; for (int i = 0; i < n; i++) { while (a[i] < (1 << 17)) { s.insert(a[i]); a[i] *= 2; } } vector b; for (auto &x: s) b.emplace_back(x); gj(b); int count = 16; while (count--) { set t; for (int i = 0; i < min(18, (int) b.size()); i++) { while (b[i] && b[i] < (1 << 17)) { t.insert(b[i]); b[i] *= 2; } } b.clear(); for (auto &x: t) b.emplace_back(x); gj(b); } long long ans = 1e18; for (int x = 1; x <= 100000; x++) { int t = x; for (int i = 0; i < min(18, (int) b.size()); i++) { if ((t ^ b[i]) < t) t ^= b[i]; } if (t == 0) ans = min(ans, sum[x]); } cout << ans << endl; return 0; }