#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    s.insert(x);
  }
  set<int> s1;
  set<int> s2;
  set<int> s3;
  for (int i : s) {
    if (i < 0)
      s1.insert(i);
    else if (i > 0) {
      s2.insert(i);
    } else {
      s3.insert(0);
    }
  }
  if (s1.size() % 2 == 0) {
    int x = *s1.begin();
    s1.erase(x);
    s3.insert(x);
  }
  if (s1.size() > 2) {
    s2.insert(*s1.begin());
    s1.erase(*s1.begin());
    s2.insert(*s1.begin());
    s1.erase(*s1.begin());
  }
  cout << s1.size() << " ";
  for (auto x : s1) cout << x << " ";
  cout << endl;
  cout << s2.size() << " ";
  for (auto x : s2) cout << x << " ";
  cout << endl;
  cout << s3.size() << " ";
  for (auto x : s3) cout << x << " ";
  cout << endl;
  return 0;
}
