#include <bits/stdc++.h>
using namespace std;
const int mod = 10e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  cout << 1 << " " << v[0] << endl;
  if (v[n - 1] <= 0) {
    cout << 2 << " " << v[1] << " " << v[2] << endl;
    cout << n - 3 << " ";
    for (int i = 3; i < n; i++) cout << v[i] << " ";
    cout << endl;
  } else {
    cout << 1 << " " << v[n - 1] << endl;
    cout << n - 2 << " ";
    for (int i = 1; i < n - 1; i++) cout << v[i] << " ";
    cout << endl;
  }
}
