#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, t;
  scanf("%d\n", &n);
  int a[100];
  int b[100];
  int c[100];
  int ca = -1, cb = -1, cc = -1, cn = 0, acb, p;
  for (i = 0; i < n - 1; ++i) {
    scanf("%d", &t);
    if (t < 0 && ca == -1) {
      ++ca;
      a[ca] = t;
    } else if (t == 0) {
      ++cc;
      c[cc] = t;
    } else {
      ++cb;
      b[cb] = t;
      if (t < 0) {
        ++cn;
        p = cb;
      }
    }
  }
  scanf("%d\n", &t);
  if (t < 0 && ca == -1) {
    ++ca;
    a[ca] = t;
  } else if (t == 0) {
    ++cc;
    c[cc] = t;
  } else {
    ++cb;
    b[cb] = t;
    if (t < 0) {
      ++cn;
      p = cb;
    }
  }
  acb = cb;
  if (cn % 2 == 1) {
    ++cc;
    c[cc] = b[p];
    b[p] = 0;
    --acb;
  }
  cout << ca + 1 << " ";
  for (i = 0; i < ca; ++i) {
    cout << a[i] << " ";
  }
  cout << a[i] << endl;
  cout << acb + 1 << " ";
  for (i = 0; i < cb; ++i) {
    if (b[i] != 0) {
      cout << b[i] << " ";
    }
  }
  if (b[i] != 0) {
    cout << b[i] << endl;
  }
  cout << cc + 1 << " ";
  for (i = 0; i < cc; ++i) {
    cout << c[i] << " ";
  }
  cout << c[i] << endl;
  return 0;
}
