#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i;
  cin >> n;
  vector<int> neg;
  vector<int> pos;
  for (i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x < 0)
      neg.push_back(x);
    else if (x > 0)
      pos.push_back(x);
  }
  cout << "1 " << neg[0] << "\n";
  neg.erase(neg.begin() + 0);
  if (pos.size() > 0) {
    cout << "1 " << pos[0] << "\n";
    pos.erase(pos.begin() + 0);
  } else {
    cout << "2 " << neg[0] << " " << neg[1] << "\n";
    neg.erase(neg.begin() + 0);
    neg.erase(neg.begin() + 0);
  }
  cout << pos.size() + neg.size() + 1;
  for (i = 0; i < neg.size(); i++) cout << " " << neg[i];
  for (i = 0; i < pos.size(); i++) cout << " " << pos[i];
  cout << " 0\n";
  return 0;
}
