#include #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, fmin; void update(ll x, ll f) { if (f < fmin) { dump(x << " " << f); fmin = f; xmin = x; } } void run() { xmin = 0, fmin = 1LL << 60; for (ll x = 1; x <= 2 * n; ++x) { ll s_upper = 2 * n / (x + 1); ll s = 1; for (int now = 0; now < n; ) { ll next = (vs[now] / x + 1) * x; auto it = lower_bound(vs.begin() + now, vs.end(), next); if (it == vs.end()) break; now = (it - vs.begin()); dump(x << " === " << now << " " << *it); s++; if (s > s_upper) break; } dump(x << " " << s) update(x, (x + 1) * s); } 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(); }