#include <bits/stdc++.h>
using namespace std;
char c;
int main() {
  int n, e = 0, m = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i], (a[i] > 0) ? e++ : 0;
  sort(a, a + n);
  cout << "1 " << a[0] << endl;
  if (e == 0) {
    cout << "2 " << a[1] << " " << a[2] << endl;
    cout << n - 3 << " ";
    for (int i = 3; i < n; i++) cout << a[i] << " ";
    return 0;
  }
  for (int i = 1; i < n; i++)
    if (a[i] == 0) m = i;
  cout << n - m - 1 << " ";
  for (int i = m + 1; i < n; i++) cout << a[i] << " ";
  cout << endl;
  cout << m << " ";
  for (int i = 1; i < m + 1; i++) cout << a[i] << " ";
}
