#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int n, v;
  cin >> n;
  int pos = 0;
  int pos2 = 0;
  int neg = 0;
  vector<int> zero;
  for (int i = 0; i < n; ++i) {
    cin >> v;
    if (v == 0) {
      zero.push_back(v);
      continue;
    }
    if (v < 0) {
      if (neg == 0)
        neg = v;
      else if (pos == 0)
        pos = v;
      else if (pos < 0 && pos2 == 0)
        pos2 = v;
      else
        zero.push_back(v);
    } else {
      if (pos == 0)
        pos = v;
      else if (pos < 0 && pos2 == 0) {
        zero.push_back(pos);
        pos = v;
      } else
        zero.push_back(v);
    }
  }
  cout << 1 << " " << neg << endl;
  if (pos > 0)
    cout << 1 << " " << pos << endl;
  else
    cout << 2 << " " << pos << " " << pos2 << endl;
  cout << zero.size();
  for (int i = 0; i < zero.size(); ++i) cout << " " << zero[i];
  cout << endl;
}
