#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  cin >> n;
  int nop = 0;
  vector<int> pos;
  vector<int> neg;
  vector<int> zero;
  pos.resize(0);
  neg.resize(0);
  zero.resize(0);
  for (i = 0; i < n; i++) {
    cin >> j;
    if (j > 0 && pos.size() == 0)
      pos.push_back(j);
    else if (j < 0 && neg.size() == 0)
      neg.push_back(j);
    else if (j != 0)
      zero.push_back(j);
  }
  if (pos.size() == 0) {
    cout << "1 " << neg[0] << endl;
    cout << "2 " << zero[0] << " " << zero[1] << endl;
    cout << (zero.size() - 1) << " 0 ";
    for (j = 2; j < zero.size(); j++) cout << zero[j] << " ";
  } else {
    cout << "1 " << neg[0] << endl;
    cout << "1 " << pos[0] << endl;
    cout << zero.size() + 1 << " 0 ";
    for (j = 0; j < zero.size(); j++) cout << zero[j] << " ";
  }
  return 0;
}
