#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, t, j;
  vector<int> a, b, c, d;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(), a.end());
  for (i = 0; i < n; i++) {
    if (a[i] == 0) {
      t = i;
      break;
    }
  }
  if (t % 2 != 0) {
    for (i = 0; i < t; i++) {
      b.push_back(a[i]);
    }
    for (j = t + 1; j < n; j++) {
      c.push_back(a[j]);
    }
    d.push_back(a[t]);
  } else {
    for (i = 0; i < t - 1; i++) {
      b.push_back(a[i]);
    }
    for (j = t + 1; j < n; j++) {
      c.push_back(a[j]);
    }
    d.push_back(a[t - 1]);
    d.push_back(a[t]);
  }
  if (c.size() == 0) {
    c.push_back(b[b.size() - 1]);
    b.pop_back();
    c.push_back(b[b.size() - 1]);
    b.pop_back();
  }
  cout << b.size() << " ";
  for (i = 0; i < b.size(); i++) cout << b[i] << " ";
  cout << endl << c.size() << " ";
  for (i = 0; i < c.size(); i++) {
    cout << c[i] << " ";
  }
  cout << endl << d.size() << " ";
  for (i = 0; i < d.size(); i++) {
    cout << d[i] << " ";
  }
}
