var data = require('fs').readFileSync('/dev/stdin', 'utf8');
var input = data.trim().split('\n');

// var input = [
// 	1819,
// 	2003,
// 	876,
// 	2840,
// 	1723,
// 	1673,
// 	3776,
// 	2848,
// 	1592,
// 	922
// ];

function findHighestHills(arr) {
	if (arr.length <= 1) {
		return arr;
	}

	var pivot = parseInt(arr.pop());
	var left = [];
	var right = [];

	while (arr.length) {
		var elem = parseInt(arr.pop());
		if (elem > pivot) {
			left.push(elem);
		} else {
			right.push(elem);
		}
	}

	var sorted = [].concat(findHighestHills(left), pivot, findHighestHills(right));
	return sorted.splice(0, 3);
}

var output = findHighestHills(input);

for (var i = 0; i < output.length; i ++) {
	console.log(output[i]);
}