#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, i, j, k, l, m;
  cin >> n;
  long long pos[1001] = {0}, neg[1001] = {0}, sum0 = 0, sump = 0, sumn = 0, x,
            y, ll = 0;
  for (i = 0; i < n; i++) {
    cin >> k;
    if (k < 0) {
      neg[(-1) * k] = 1;
      sumn++;
    } else if (k > 0) {
      pos[k] = 1;
      sump++;
    } else
      sum0++;
  }
  if (sump) {
    if (sumn % 2 == 0) {
      ll = 0;
      for (i = 0; i < 1001; i++) {
        if (neg[i]) {
          ll = (-1) * i;
          neg[i] = 0;
        }
        if (ll) break;
      }
      sumn--;
      sum0++;
    }
    cout << sumn << " ";
    for (i = 0; i < 1001; i++)
      if (neg[i]) cout << (-1) * i << " ";
    cout << "\n" << sump << " ";
    for (i = 0; i < 1001; i++)
      if (pos[i]) cout << i << " ";
    cout << "\n" << sum0 << " ";
    if (ll) sum0--;
    for (i = 0; i < sum0; i++) cout << "0 ";
    if (ll) cout << ll;
  } else {
    ll = 0;
    if (sumn % 2 == 0) {
      ll = 0;
      for (i = 0; i < 1001; i++) {
        if (neg[i]) {
          ll = (-1) * i;
          neg[i] = 0;
        }
        if (ll) break;
      }
      sumn--;
      sum0++;
    }
    if (sump == 0) {
      x = 0, y = 0;
      for (i = 0; i < 1001; i++) {
        if (neg[i] && !x) {
          x = (-1) * i;
          neg[i] = 0;
        }
        if (neg[i] && x && !y) {
          y = (-1) * i;
          neg[i] = 0;
        }
        if (x && y) break;
      }
      sumn -= 2;
    }
    cout << sumn << " ";
    for (i = 0; i < 1001; i++)
      if (neg[i]) cout << (-1) * i << " ";
    cout << "\n"
         << "2 " << x << " " << y;
    cout << "\n" << sum0 << " ";
    if (ll) sum0--;
    for (i = 0; i < sum0; i++) cout << "0 ";
    if (ll) cout << ll;
  }
  return 0;
}
