#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x ostream& operator<<(ostream& os, const pair& p){ return os << "{" << p.first << ", " << p.second << "}"; } template ostream& operator<<(ostream& os, const vector& obj) { os << "{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template ostream& operator<<(ostream& os, const set& obj) { os << "set{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } template ostream& operator<<(ostream& os, const map& obj) { os << "map{"; for (const auto& e : obj) os << e << ", "; return os << "}"; } #ifdef ONLINE_JUDGE #define dump(expr) ; #else #define dump(expr) { cerr << "\033[33m#L" << __LINE__ << ": " << expr << "\033[39m" << endl; } #endif namespace solver { int n; vector vs; void read() { cin >> n; vs.resize(n); for (int i : range(n)) cin >> vs[i]; } ll xmin = 0, fmin = 1LL << 60; void update(ll x, ll f) { if (f < fmin) { dump(x << " " << f); fmin = f; xmin = x; } } void run() { const ll L = 100; const ll M = 10000000; // const ll L = 2; // const ll M = 1000; for (ll x = 1; x <= 100; ++x) { set st; for (int i : range(n)) st.insert(vs[i] / x); ll f = (x + 1) * st.size(); update(x, f); } vector seen(M / L + 10); for (ll x = 100; x * x <= 2 * M; ++x) { ll uni = 0; for (int i : range(n)) { ll div = vs[i] / x; if (seen[div] != x) seen[div] = x, uni++; } ll f = (x + 1) * uni; update(x, f); } cout << xmin << endl; cout << fmin << endl; } } int main(int argc, char** argv) { cerr << fixed << setprecision(12); cout << fixed << setprecision(12); int testcase = 1; if (argc > 1) testcase = atoi(argv[1]); while (testcase--) { solver::read(); } solver::run(); }