/* -*- coding: utf-8 -*- * * 2221.cc: No.2221 Set X - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ using ll = long long; /* global variables */ int as[MAX_N + 1]; /* subroutines */ ll f(int n, int x, ll minf) { int c = 1; for (int i = 0; i < n;) { int ai = as[i] / x; int j0 = i, j1 = n + 1; while (j0 + 1 < j1) { int j = (j0 + j1) / 2; if (as[j] / x > ai) j1 = j; else j0 = j; } i = j1; if (i < n) { c++; if ((ll)(x + 1) * c >= minf) return minf; } } return (ll)(x + 1) * c; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); as[n] = as[n - 1] * 2 + 2; int maxx = n * 2, minx = 1; ll minf = n * 2; for (int x = 1; x < maxx; x++) { ll fx = f(n, x, minf); if (minf > fx) minf = fx, minx = x; //printf(" %lld", fx); } //putchar('\n'); printf("%d\n%lld\n", minx, minf); return 0; }