#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  sort(arr, arr + n);
  int pos = 0, neg = 0, zero;
  for (int i = 0; i < n; i++) {
    if (arr[i] < 0)
      neg++;
    else if (arr[i] > 0)
      pos++;
    if (arr[i] == 0) zero = i;
  }
  if (neg % 2 == 1 && pos > 0) {
    cout << zero << " ";
    for (int i = 0; i < zero; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
    cout << n - zero - 1 << " ";
    for (int i = zero + 1; i < n; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
    cout << "1 0" << endl;
  } else if (neg % 2 == 1 && pos == 0) {
    cout << "1 ";
    cout << arr[0] << endl;
    cout << n - 2 << " ";
    for (int i = 1; i < n - 1; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
    cout << "1 0" << endl;
  } else if (neg % 2 == 0 && pos > 1) {
    cout << zero - 1 << " ";
    for (int i = 0; i < zero - 1; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
    cout << n - zero - 1 << endl;
    for (int i = zero + 1; i < n; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
    cout << "2 ";
    cout << arr[zero - 1] << " 0" << endl;
  } else if (neg % 2 == 0 && pos == 0) {
    cout << "1 ";
    cout << arr[0] << endl;
    cout << n - 3 << " ";
    for (int i = 1; i < n - 2; i++) {
      cout << arr[i] << " ";
    }
    cout << endl;
    cout << "2 ";
    cout << arr[zero - 1] << " 0" << endl;
  }
  return 0;
}
