#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int a[n];
  vector<long long int> neg, pos, zer;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      neg.push_back(a[i]);
    } else if (a[i] == 0) {
      zer.push_back(a[i]);
    } else {
      pos.push_back(a[i]);
    }
  }
  if (pos.size() == 0) {
    long long int k = neg[neg.size() - 1];
    neg.pop_back();
    pos.push_back(k);
    k = neg[neg.size() - 1];
    neg.pop_back();
    pos.push_back(k);
  }
  if (neg.size() % 2 == 0) {
    long long int k = neg[neg.size() - 1];
    neg.pop_back();
    zer.push_back(k);
  }
  cout << neg.size() << " ";
  for (int i = 0; i < neg.size(); i++) {
    cout << neg[i] << " ";
  }
  cout << endl;
  cout << pos.size() << " ";
  for (int i = 0; i < pos.size(); i++) {
    cout << pos[i] << " ";
  }
  cout << endl;
  cout << zer.size() << " ";
  for (int i = 0; i < zer.size(); i++) {
    cout << zer[i] << " ";
  }
}
