#include #include #include #include using namespace std; using ll = long long; const ll N = 2 * 100000 + 10; struct Segment { ll q, L, R; }; vector floor_decomposition(ll x) { vector res; ll R = 1e18; while (R) { ll q = x / R; ll L = x / (q + 1); res.push_back({q, L, R}); R = L; } return res; } vector> merge(const vector &A, const vector &B) { int i = 0, j = 0; vector> ans; ll X = 1e18; while (i < A.size() && j < B.size()) { if (A[i].q < B[j].q) { ans.push_back({max(A[i].L, B[j].L), X}); } X = max(A[i].L, B[j].L); if (A[i].L < B[j].L) { j++; } else { i++; } } return ans; } int main() { ll n; cin >> n; vector a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector rui(N + 1, 0); auto pre = floor_decomposition(a[0]); for (int i = 0; i < n - 1; i++) { auto now = floor_decomposition(a[i + 1]); for (auto &[l, r] : merge(pre, now)) { if (r + 1 <= N) { rui[r + 1]--; } if (l + 1 <= N) { rui[l + 1]++; } } pre = now; } for (int i = 0; i < N; i++) { rui[i + 1] += rui[i]; } ll ans = LLONG_MAX; ll I = -1; for (ll i = 1; i < N; i++) { ll val = (1 + rui[i]) * (i + 1); if (ans > val) { ans = val; I = i; } } cout << I << endl; cout << ans << endl; return 0; }