#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, p, neg = 0, count, flip = 0;
  cin >> n;
  vector<int> v;
  vector<int> ne;
  vector<int> po;
  vector<int> o;
  for (int i = 0; i < n; i++) {
    cin >> p;
    if (p < 0) {
      neg++;
    }
    v.push_back(p);
  }
  count = neg - 1;
  for (int i = 0; i < n; i++) {
    if (v.at(i) < 0 && flip == 0) {
      ne.push_back(v.at(i));
      flip++;
    } else {
      if ((v.at(i) < 0 && neg % 2 == 0 && count > 1) ||
          (v.at(i) < 0 && neg % 2 != 0) || v.at(i) > 0) {
        po.push_back(v.at(i));
        if (v.at(i) < 0) {
          count--;
        }
      } else {
        o.push_back(v.at(i));
      }
    }
  }
  cout << "1"
       << " " << ne.at(0) << endl;
  cout << po.size() << " ";
  for (int i = 0; i < po.size(); i++) {
    cout << po.at(i) << " ";
  }
  cout << endl;
  cout << o.size() << " ";
  for (int i = 0; i < o.size(); i++) {
    cout << o.at(i) << " ";
  }
  cout << endl;
  return 0;
}
