#include <bits/stdc++.h>
using namespace std;
bool isneg(int i) { return i < 0; }
int main() {
  int n;
  cin >> n;
  int arr[n];
  bool used[n];
  int printed = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    used[i] = false;
  }
  int nneg = count_if(arr, arr + n, isneg);
  int nzer = count(arr, arr + n, 0);
  cout << 1 << " ";
  printed += 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] < 0) {
      cout << arr[i] << " ";
      used[i] = true;
      break;
    }
  }
  cout << endl;
  if (nneg + nzer == n) {
    cout << 2 << " ";
    printed += 2;
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (arr[i] < 0 && used[i] == false) {
        cout << arr[i] << " ";
        used[i] = true;
        count++;
        if (count == 2) break;
      }
    }
  } else {
    cout << 1 << " ";
    printed += 1;
    for (int i = 0; i < n; i++) {
      if (arr[i] > 0 && used[i] == false) {
        cout << arr[i] << " ";
        used[i] = true;
        break;
      }
    }
  }
  cout << endl;
  cout << n - printed << " ";
  for (int i = 0; i < n; i++) {
    if (used[i] == false) {
      cout << arr[i] << " ";
    }
  }
  return 0;
}
