#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y, z = 0, k, t = 0, e, g;
  vector<int> zero;
  vector<int> po;
  vector<int> ne;
  cin >> x;
  g = x;
  while (x--) {
    cin >> y;
    if (y < 0) {
      ne.push_back(y);
      k *= y;
    }
    if (y > 0) {
      po.push_back(y);
    }
    if (y == 0) {
      zero.push_back(y);
    }
    if (y < 0 || y == 0) t++;
  }
  if (t == g) {
    for (int i = 0; i < 2; i++) {
      e = ne.back();
      po.push_back(e);
      ne.pop_back();
    }
  }
  k = ne.size();
  if (k % 2 == 0) {
    e = ne.back();
    zero.push_back(e);
    ne.pop_back();
  }
  cout << ne.size() << " ";
  for (int i = 0; i < ne.size(); i++) cout << ne[i] << " ";
  cout << endl;
  cout << po.size() << " ";
  for (int i = 0; i < po.size(); i++) cout << po[i] << " ";
  cout << endl;
  cout << zero.size() << " ";
  for (int i = 0; i < zero.size(); i++) cout << zero[i] << " ";
  cout << endl;
  return 0;
}
