#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, g = 0, c = 0, j = 0;
  cin >> n;
  int a[n];
  vector<int> v, v1, v2;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) g++;
    if (a[i] < 0 && g == 1) {
      v.push_back(a[i]);
      j = i;
    }
    if (a[i] > 0 || (g > 1 && a[i] < 0)) v1.push_back(a[i]);
    if (a[i] == 0) v2.push_back(a[i]);
  }
  sort(v1.begin(), v1.end());
  reverse(v1.begin(), v1.end());
  int l = v1.size();
  int l2 = v2.size();
  if (g % 2 == 0) {
    v2.push_back(v1[l - 1]);
    l--;
    l2++;
  }
  cout << "1 " << v[0] << endl;
  cout << l << " ";
  for (int i = 0; i < l; i++) cout << v1[i] << " ";
  cout << endl << l2 << " ";
  for (int i = 0; i < v2.size(); i++) cout << v2[i] << " ";
  return 0;
}
