#include <bits/stdc++.h>
using namespace std;
int i, n, a[103];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int kn = 0, kz = 0, kp = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] < 0) kn++;
    if (a[i] == 0) kz++;
    if (a[i] > 0) kp++;
  }
  if (kp > 0) {
    cout << 1 << " " << a[1] << '\n';
    cout << 1 << " " << a[n] << '\n';
    cout << n - 2 << " ";
    for (i = 2; i <= n - 1; i++) cout << a[i] << " ";
  } else {
    cout << 1 << " " << a[1] << '\n';
    cout << 2 << " ";
    cout << a[2] << " " << a[3];
    cout << '\n';
    cout << n - 3 << " ";
    for (i = 4; i <= n; i++) cout << a[i] << " ";
  }
  return 0;
}
