#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int c[N];
int main()
{
int n, resC = 0;
long long res = 0;
scanf("%d", &n);
for (int i = 1; i <= n; i ++ ) scanf("%d", &c[i]);
sort(c + 1, c + n + 1);
for (int i = 1; i <= n; i ++ )
if (c[i] * 1ll * (n - i + 1) > res)
res = c[i] * 1ll * (n - i + 1), resC = c[i];
printf("%lld %d", res, resC);
return 0;
}