#include <bits/stdc++.h>
using namespace std;
int n, sum, x;
vector<int> a, b, c;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    if (x < 0) a.push_back(x);
    if (x > 0) b.push_back(x);
    if (x == 0) c.push_back(x);
  }
  if (b.size() == 0)
    for (int i = 0; i < 2; i++) b.push_back(a.back()), a.pop_back();
  if (a.size() % 2 == 0) c.push_back(a.back()), a.pop_back();
  cout << a.size() << " ";
  for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
  cout << endl << b.size() << " ";
  for (int i = 0; i < b.size(); i++) cout << b[i] << " ";
  cout << endl << c.size() << " ";
  for (int i = 0; i < c.size(); i++) cout << c[i] << " ";
  return 0;
}
