#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, pc = 0, nnum = 0;
  cin >> n;
  vector<int> v(n), b, c;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] > 0) pc++;
  }
  for (int i = 0; i < n; i++) {
    if (v[i] < 0) {
      if (nnum == 0)
        nnum = v[i];
      else {
        if (pc == 0) {
          if (b.size() < 2)
            b.push_back(v[i]);
          else
            c.push_back(v[i]);
        } else
          c.push_back(v[i]);
      }
    } else if (v[i] > 0)
      b.push_back(v[i]);
    else
      c.push_back(v[i]);
  }
  cout << 1 << " " << nnum << endl;
  cout << b.size() << " ";
  for (int i = 0; i < b.size(); i++) {
    cout << b[i] << " ";
  }
  cout << endl;
  cout << c.size() << " ";
  for (int i = 0; i < c.size(); i++) cout << c[i] << " ";
}
