#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int a[101];
  bool b[101];
  memset(b, false, sizeof(b));
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << "1 ";
  for (int i = 0; i < n; i++) {
    if (a[i] < 0) {
      cout << a[i] << endl;
      b[i] = true;
      break;
    }
  }
  int nx = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      b[i] = true;
      nx = 1;
      cout << nx << " " << a[i] << endl;
      goto ra;
    }
    for (int j = i + 1; j < n; j++) {
      if (!b[i] && !b[j] && a[i] * a[j] > 0) {
        b[i] = b[j] = true;
        nx = 2;
        cout << nx << " " << a[i] << " " << a[j] << endl;
        goto ra;
      }
    }
  }
ra:
  cout << n - 1 - nx << " ";
  for (int i = 0; i < n; i++) {
    if (!b[i]) cout << a[i] << " ";
  }
  return 0;
}
