#include <bits/stdc++.h>
using namespace std;
int a[100000];
int main() {
  vector<int> b, c, d;
  int n, i, k = 0, k1 = 0, k2 = 0, k3 = 0, k4 = 0, k5 = 0, k6 = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < 0)
      b.push_back(a[i]);
    else if (a[i] > 0)
      c.push_back(a[i]);
    else if (a[i] == 0)
      d.push_back(0);
  }
  if (c.size() == 0)
    c.push_back(b[b.size() - 2]), c.push_back(b[b.size() - 1]), b.pop_back(),
        b.pop_back();
  if (b.size() % 2 == 0) d.push_back(b[b.size() - 1]), b.pop_back();
  cout << b.size() << " ";
  for (i = 0; i < b.size(); i++) cout << b[i] << " ";
  cout << endl << c.size() << " ";
  for (i = 0; i < c.size(); i++) cout << c[i] << " ";
  cout << endl << d.size() << " ";
  for (i = 0; i < d.size(); i++) cout << d[i] << " ";
  return 0;
}
