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