#include <fstream>
#include <stdint.h>

using namespace std;

int main()
{
	ifstream input;
	ofstream output;
	int max = INT32_MIN;
	int count = 0;
	int n;

	input.open("timmax.inp");
	input >> n;

	int a[n];

	for (int i = 0; i < n; i++)
	{
		input >> a[i];
		if (a[i] > max) max = a[i];
	}
	input.close();

	output.open("timmax.out");
	output << max << ' ';
	for (int i = 0; i < n; i++)
	{
		if (a[i] == max) output << a[i] << ' ';
	}
	output.close();
	return 0;
}