#include <iostream>
#include <vector>
#include <iterator>
 
using namespace std;
 
int main()
{
	int size_of_the_sequence;
	int temp = 0; //счетчик
	cin >> size_of_the_sequence;	
	vector<double> v1 (size_of_the_sequence);
	vector<double> v2;
	bool h = true, l = true;
	for (int i = 0; i < size_of_the_sequence; i++)
	{
		cin >> v1[i];
		if (i % 4 == 0) temp++;
	}
	for (int i = 1; i < size_of_the_sequence; i++)
	{
		if (v1[i - 1] <= v1[i])
		{
			l = false;
		}
		if (v1[i - 1] >= v1[i])
		{
			h = false;
		}
	}
	if (!l && !h)//исходная последовательность не упорядочена ни по возрастанию, ни по убыванию
	{
		v2.resize(size_of_the_sequence - temp);
		int size_of_the_sequence = 0;
		for (int i = 0; i < v1.size(); i++)
		{
			if (i % 4 == 0) { size_of_the_sequence++; continue; }
			else v2[i - size_of_the_sequence] = v1[i];
		}
		v1.resize(size_of_the_sequence - temp);
		v1 = v2;
		v1.shrink_to_fit();
		v2.clear();
	}
	copy(v1.begin(), v1.end(), ostream_iterator<double>(cout, " "));//выводим исходную последовательность без измений
	return 0;
}