|
#include<iostream>
using namespace std;
const int A = 10e6;
long long arr[A];
int main() {
long long n, m = 0, ans = 0,x, max_ = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> x;
max_ = max(max_, x);
arr[x]++;
}
for (int i = max_ - 1; i > 0; i--) {
arr[i] = arr[i] + arr[i + 1];
}
for (int i = max_; i >= 1; i--) {
if (m <= arr[i] * i) {
ans = i;
m = arr[i] * i;
}
}
cout << m << " " << ans;
}
|
|