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