#include
int main(){
unsigned int m = 0;
std::cin >> m;
int * c = new int[m];
int * t = new int[m];
for (unsigned int i = 0,n = 0; i < m; ++i) {
std::cin >> c[i];
(c[i] > 0) ? t[n++] = c[i]: t[m-(i-n)-1] = c[i];
}
for (unsigned int i = 0; i < m; ++i) std::cout << c[i] << ',';</span>
std::cout << std::endl;</span>
for (unsigned int i = 0; i < m; ++i) std::cout << t[i] << ',';</span>
delete c;
delete t;
return 0;
}