#include <bits/stdc++.h>
using namespace std;
void oj() {}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  oj();
  long long n, pos = 0, neg = 0;
  cin >> n;
  vector<long long> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (v[i] > 0)
      pos++;
    else if (v[i] < 0)
      neg++;
  }
  sort(v.begin(), v.end());
  cout << 1 << " " << v[0];
  if (pos > 0) {
    cout << endl << 1 << " " << v[n - 1] << endl << n - 2 << " ";
    for (int i = 1; i < n - 1; i++) cout << v[i] << " ";
  } else {
    cout << endl << 2 << " " << v[1] << " " << v[2] << endl << n - 3 << " ";
    for (int i = 3; i < n; i++) cout << v[i] << " ";
  }
  return 0;
}
