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