#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, pc = 0, nc = 0, na = 0, nna = 0, c;
  int arr[110];
  vector<int> narr, parr, alosarr;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c;
    if (c < 0)
      nc += 1;
    else if (c > 0)
      pc += 1;
    arr[i] = c;
  }
  for (int i = 0; i < n; i++) {
    if (arr[i] < 0) {
      if (nc >= 3) {
        if (na == 0) {
          narr.push_back(arr[i]);
          na += 1;
        } else {
          if (nna < 2) {
            parr.push_back(arr[i]);
            nna += 1;
          } else
            alosarr.push_back(arr[i]);
        }
      } else {
        if (na == 0) {
          narr.push_back(arr[i]);
          na += 1;
        } else
          alosarr.push_back(arr[i]);
      }
    } else if (arr[i] > 0)
      parr.push_back(arr[i]);
    else
      alosarr.push_back(arr[i]);
  }
  cout << narr.size() << " ";
  for (int i = 0; i < narr.size(); i++) cout << narr[i] << " ";
  cout << endl;
  cout << parr.size() << " ";
  for (int i = 0; i < parr.size(); i++) cout << parr[i] << " ";
  cout << endl;
  cout << alosarr.size() << " ";
  for (int i = 0; i < alosarr.size(); i++) {
    cout << alosarr[i] << " ";
  }
  cout << endl;
  return 0;
}
