#include #include using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; int main(){ int n; cin >> n; set xl; vector> r; map sashi; int cnt = 0; int x = 0; vector a(n); vector b(n); map ars; int am = 0; ll setnum = 0; for (int i=0; i> x; b[i] = x; if (ars[0] == 0){ setnum++; } ars[0]++; am = max(am, x); if (x > 0){ if (xl.find(x) == xl.end()){ r.push_back({i}); sashi[x] = cnt; cnt++; xl.insert(x); }else{ r[sashi[x]].push_back(i); } } } ll ans = (ll)am + 2; int ansx = am + 1; //return 0; while (!xl.empty()){ auto xind = xl.end(); xind--; //cout << *xind << endl; int x = *xind; xl.erase(xind); for (int j: r[sashi[x]]){ ars[a[j]]--; if (ars[a[j]] == 0){ setnum--; } a[j] = b[j] / x; //cout << a[j] << endl; if (ars[a[j]] == 0){ setnum++; } ars[a[j]]++; int targ = b[j] / (a[j] + 1); if (targ > 0){ if (xl.find(targ) == xl.end()){ r.push_back({j}); sashi[targ] = cnt; cnt++; xl.insert(targ); }else{ r[sashi[targ]].push_back(j); } } } if (ans >= setnum * (x + 1)){ ans = setnum * (x + 1); ansx = x; } //cout << setnum * (x + 1) << " " << x << endl; } cout << ansx << endl; cout << ans << endl; }