#include <bits/stdc++.h>
using namespace std;
int a, b, c, e, x, y, m, i, j;
vector<int> v;
vector<int> u;
vector<int> n;
vector<int> d;
int main() {
  cin >> b;
  for (i = 0; i < b; i++) {
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  if (v[v.size() - 1] == 0) {
    u.push_back(v[0]);
    for (i = 3; i < v.size(); i++) n.push_back(v[i]);
    d.push_back(v[1]);
    d.push_back(v[2]);
    cout << 1 << " " << u[0] << endl;
    cout << 2 << " " << d[0] << " " << d[1] << endl;
    cout << n.size() << " ";
    for (i = 0; i < n.size(); i++) cout << n[i] << " ";
    return 0;
  }
  u.push_back(v[0]);
  d.push_back(v[v.size() - 1]);
  for (i = 1; i <= v.size() - 2; i++) {
    n.push_back(v[i]);
  }
  cout << 1 << " " << u[0] << endl;
  cout << 1 << " " << d[0] << endl;
  cout << n.size() << " ";
  for (i = 0; i < n.size(); i++) {
    cout << n[i] << " ";
  }
  return 0;
}
