/* -*- coding: utf-8 -*- * * 3073.cc: No.3073 Fraction Median - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 1500000; const int CNT = 70; const int INF = 1 << 30; /* typedef */ using ll = long long; /* global variables */ int as[MAX_N]; /* subroutines */ ll calc(int n, double f) { ll sum = 0; for (int i = 0; i < n; i++) { int j = n; if (as[i] * f < INF) { int x = (int)(as[i] * f); j = upper_bound(as, as + n, x) - as; } if (j > i) j--; sum += j; } return sum; } /* main */ int main() { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", as + i); sort(as, as + n); ll k = (ll)n * (n - 1) / 2; double f0 = 0.0, f1 = 1e9 + 1; for (int cnt = 0; cnt < CNT; cnt++) { double f = (f0 + f1) / 2; ll c = calc(n, f); //printf(" f=%lf, c=%lld\n", f, c); if (c < k) f0 = f; else f1 = f; } //printf(" f1=%lf\n", f1); int x = 0, y = 1; for (int i = 0; i < n; i++) { int fi = (int)(as[i] * f1); int j = upper_bound(as, as + n, fi) - as; //printf(" i=%d, j=%d\n", i, j); while (--j >= 0) if (i != j) { if ((ll)as[j] * y > (ll)x * as[i]) x = as[j], y = as[i]; break; } } int g = gcd(x, y); x /= g, y /= g; printf("%d %d\n", x, y); return 0; }