#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n], i;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << "1"
       << " " << a[0] << "\n";
  if (a[n - 1] > 0) {
    cout << "1"
         << " " << a[n - 1] << "\n";
    cout << n - 2 << " ";
    for (i = 1; i < n - 1; i++) {
      cout << a[i] << " ";
    }
  } else {
    cout << "2"
         << " " << a[1] << " " << a[2] << "\n";
    cout << n - 3 << " ";
    for (i = 3; i < n; i++) {
      cout << a[i] << " ";
    }
  }
}
