#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  vector<int> n, z, p;
  for (int i = 0; i < k; i++) {
    int temp;
    cin >> temp;
    if (temp < 0) {
      n.push_back(temp);
    } else if (temp == 0) {
      z.push_back(temp);
    } else {
      p.push_back(temp);
    }
  }
  int n_size = n.size();
  if (p.size() == 0) {
    p.push_back(n[n_size - 1]);
    p.push_back(n[n_size - 2]);
    n_size = n_size - 2;
  }
  if (!(n_size & 1)) {
    z.push_back(n[n_size - 1]);
    n_size -= 1;
  }
  cout << n_size;
  for (int i = 0; i < n_size; i++) {
    cout << " " << n[i];
  }
  cout << "\n" << p.size();
  for (int i = 0; i < p.size(); i++) {
    cout << " " << p[i];
  }
  cout << "\n" << z.size();
  for (int i = 0; i < z.size(); i++) {
    cout << " " << z[i];
  }
}
