#include using namespace std; using int64 = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; if (!(cin >> N)) return 0; vector A(N); for (int i = 0; i < N; ++i) cin >> A[i]; long long maxA = A.back(); // Collect candidate widths vector cand; // Always reasonable to try small widths directly long long LIM = 100000; // can be tuned; N up to 1e5, A[i] up to 1e9 for (long long w = 1; w * w <= maxA; ++w) cand.push_back(w); // For each A[i], add floor divisions that can appear as optimal W for (int i = 0; i < N; ++i) { long long x = A[i]; if (x == 0) continue; long long t = sqrtl((long double)x); for (long long k = 1; k <= t; ++k) { long long w = x / k; // floor(x / k) if (w >= 1) cand.push_back(w); if (w - 1 >= 1) cand.push_back(w - 1); } } sort(cand.begin(), cand.end()); cand.erase(unique(cand.begin(), cand.end()), cand.end()); auto cost = [&](long long W) -> long long { long long prev = -1, cnt = 0; for (int i = 0; i < N; ++i) { long long s = A[i] / W; if (s != prev) { ++cnt; prev = s; } } return cnt * (W + 1); }; long long bestW = 1; long long bestCost = cost(1); for (long long W : cand) { if (W <= 0) continue; long long c = cost(W); if (c < bestCost || (c == bestCost && W < bestW)) { bestCost = c; bestW = W; } } cout << bestW << "\n" << bestCost << "\n"; return 0; }