#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 2;
const long long int mod = 1e9 + 7;
vector<int> sfr, msbt, mnf;
long long int ta, mx, f[N];
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == 0)
      sfr.push_back(a);
    else if (a > 0)
      msbt.push_back(a);
    else
      mnf.push_back(a);
  }
  if (!msbt.size()) {
    msbt.push_back(mnf.back());
    mnf.pop_back();
    msbt.push_back(mnf.back());
    mnf.pop_back();
  }
  if (!(mnf.size() % 2)) sfr.push_back(mnf.back()), mnf.pop_back();
  cout << mnf.size() << ' ';
  for (int i = 0; i < mnf.size(); i++) cout << mnf[i] << " ";
  cout << '\n' << msbt.size() << " ";
  for (int i = 0; i < msbt.size(); i++) cout << msbt[i] << " ";
  cout << '\n' << sfr.size() << " ";
  for (int i = 0; i < sfr.size(); i++) cout << sfr[i] << " ";
}
