#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> arr;
  vector<int> pos;
  vector<int> neg;
  vector<int> zero;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    arr.push_back(x);
  }
  for (int i = 0; i < arr.size(); i++) {
    if (arr[i] > 0) {
      pos.push_back(arr[i]);
    } else if (arr[i] == 0) {
      zero.push_back(arr[i]);
    }
  }
  int index1 = -1, index2 = -1;
  if (pos.size() == 0) {
    for (int i = 0; i < arr.size(); i++) {
      if (arr[i] < 0) {
        if (pos.size() == 0) {
          pos.push_back(arr[i]);
          index1 = i;
        } else if (pos.size() % 2 == 1) {
          pos.push_back(arr[i]);
          index2 = i;
        }
      }
    }
  }
  for (int i = 0; i < arr.size(); i++) {
    if (arr[i] < 0 && i != index1 && i != index2) {
      if (neg.size() % 2 == 0) {
        neg.push_back(arr[i]);
      } else {
        zero.push_back(arr[i]);
      }
    }
  }
  cout << neg.size() << " ";
  for (int i = 0; i < neg.size(); i++) {
    cout << neg[i] << " ";
  }
  cout << endl;
  cout << pos.size() << " ";
  for (int i = 0; i < pos.size(); i++) {
    cout << pos[i] << " ";
  }
  cout << endl;
  cout << zero.size() << " ";
  for (int i = 0; i < zero.size(); i++) {
    cout << zero[i] << " ";
  }
}
