#include <iostream>
using namespace std;
void bac(int x[], int &p1, int &p2)
{
int pozitivIndex = -1;
bool ok = true;
for (int i = p1; i <= p2 && ok; i++)
if (x[i] > 0)
{
pozitivIndex = i;
ok = false;
}
int negativIndex = -1;
ok = true;
for (int i = p2; i >= p1 && ok; i--)
if (x[i] < 0)
{
negativIndex = i;
ok = false;
}
if (pozitivIndex != -1 && negativIndex != -1)
{
int aux = x[pozitivIndex];
x[pozitivIndex] = x[negativIndex];
x[negativIndex] = aux;
p1 = pozitivIndex;
p2 = negativIndex;
}
}
int main()
{
int x[100], n;
cin >> n;
cin >> x[0];
for (int i = 1; i < n; i++)
{
cin >> x[i];
if (x[i] < 0)
{
int p1 = 0, p2 = i;
bac(x, p1, p2);
}
}
cout << endl;
for (int i = 0; i <= n / 2 - 1; i++)
{
int aux = x[i];
x[i] = x[n-1-i];
x[n-1-i] = aux;
}
for (int i = 0; i < n; i++)
cout << x[i] << ' ';
return 0;
}