cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; ++s[a[i]]; m = max(a[i], m), sum += a[i]; } for (int i = 1; i <= m; ++i) s[i] += s[i - 1]; ll ans = 0; for (int i = 2; i <= m; ++i) { ll sum = 0; for (int j = i, k = 1; j <= m; j += i, ++k) sum += (ll) (s[min(m, j + i - 1)] - s[j - 1]) * k * (i - 1); ans = max(ans, sum); } cout << sum - ans << "\n"; return0; }