#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
int pos[MAXN];
int neg[MAXN];
int zero[MAXN];
int main() {
  int n;
  cin >> n;
  int count0 = 0, poscount = 0, negcount = 0, a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a > 0) {
      pos[poscount] = a;
      poscount++;
    } else if (a == 0)
      count0++;
    else {
      neg[negcount] = a;
      negcount++;
    }
  }
  if (poscount == 0) {
    poscount += 2;
    pos[0] = neg[negcount - 1];
    pos[1] = neg[negcount - 2];
    negcount -= 2;
  }
  if (negcount % 2 == 0) {
    negcount--;
    count0++;
    zero[count0 - 1] = neg[negcount];
  }
  cout << negcount << ' ';
  for (int i = 0; i < negcount; i++) {
    cout << neg[i] << ' ';
  }
  cout << endl;
  cout << poscount << ' ';
  for (int i = 0; i < poscount; i++) cout << pos[i] << ' ';
  cout << endl;
  cout << count0 << ' ';
  for (int i = 0; i < count0; i++) cout << zero[i] << ' ';
  cout << endl;
  return 0;
}
