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