#include <bits/stdc++.h>
using namespace std;
int n, t;
deque<int> zero, neg, pos;
void printD(deque<int> a) {
  cout << a.size() << " ";
  for (int i = 0; i < a.size(); i++) cout << a[i] << " ";
  cout << endl;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &t);
    if (t == 0)
      zero.push_back(t);
    else
      pos.push_back(t);
  }
  sort(pos.begin(), pos.end());
  neg.push_back(pos[0]);
  pos.pop_front();
  int j = 0;
  while (j < pos.size() and pos[j] < 0) j++;
  if (j % 2 == 1) {
    zero.push_back(pos[0]);
    pos.pop_front();
  }
  printD(neg);
  printD(pos);
  printD(zero);
  return 0;
}
