#include <iostream>
#include <algorithm>
#include <vector>

void poisk(std::vector<int> & massivchik)
{
	int max = *std::max_element(massivchik.begin(), massivchik.end(), 
	[](const int & a, const int & b)
	{
		return a < b;
	});
	for_each(massivchik.begin(), massivchik.end(),
	[&max](const int & value)
	{
		if (!(max - value > 1))
			std::cout << value << " ";
	});
}

int main()
{
	std::vector<int> proverochka = { 5, 6, 2, 4, 6, 5, 7, 4, 5, 3, 1, 1, 3};
	poisk(proverochka);
	return 0;
}