#include <bits/stdc++.h>
using namespace std;
long long int a, b;
int main() {
  int n, j;
  cin >> n;
  bool neg = false, pos = false;
  vector<vector<int> > x(2);
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> j;
    if (j < 0 && neg == false) {
      x[0].push_back(j);
      neg = true;
    } else if (j > 0 && pos == false) {
      x[1].push_back(j);
      pos = true;
    } else
      v.push_back(j);
  }
  cout << 1 << " " << x[0][0] << endl;
  if (pos == false) {
    sort(v.begin(), v.end());
    cout << 2 << " " << v[0] << " " << v[1] << endl;
    cout << v.size() - 2 << " ";
    for (int i = 2; i < v.size(); i++) cout << v[i] << " ";
    cout << endl;
  } else {
    cout << 1 << " " << x[1][0] << endl;
    cout << v.size() << " ";
    for (int i = 0; i < v.size(); i++) cout << v[i] << " ";
  }
}
