#include <bits/stdc++.h>
using namespace std;
void show(vector<long long> nums) {
  cout << nums.size() << " ";
  for (int i = 0; i < nums.size(); i++) cout << nums[i] << " ";
  cout << endl;
}
int main() {
  long long n, c = 0, k1 = 0, k2 = 0;
  cin >> n;
  vector<long long> nums(n, 0), f, s, t;
  for (int i = 0; i < n; i++) cin >> nums[i];
  sort(nums.begin(), nums.end());
  for (int i = 0; i < n; i++)
    if (nums[i] < 0) c++;
  for (int i = 0; i < n; i++) {
    if (nums[i] == 0)
      t.push_back(nums[i]);
    else if (nums[i] < 0) {
      if (c % 2 == 0) {
        if (c > 3) {
          if (k1 < 2) {
            k1++;
            s.push_back(nums[i]);
          } else if (k2 < 1) {
            k2++;
            t.push_back(nums[i]);
          } else
            f.push_back(nums[i]);
        } else if (c <= 3 && k2 < 1) {
          k2++;
          t.push_back(nums[i]);
        } else
          f.push_back(nums[i]);
      } else {
        if (nums[n - 1] == 0 && k1 < 2) {
          k1++;
          s.push_back(nums[i]);
        } else
          f.push_back(nums[i]);
      }
    } else
      s.push_back(nums[i]);
  }
  show(f);
  show(s);
  show(t);
  return 0;
}
