#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
int A[maxn];
vector<int> v[3];
int main() {
  int n;
  int z = 3, w = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
    if (A[i] > 0) w = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (A[i] == 0) v[2].push_back(i);
    if (A[i] > 0) v[1].push_back(i);
    if (A[i] < 0) {
      if (w) {
        if (z)
          v[0].push_back(i), z = 0;
        else
          v[2].push_back(i);
      } else {
        if (z > 1)
          v[1].push_back(i), z--;
        else if (z == 1)
          v[0].push_back(i), z--;
        else
          v[2].push_back(i);
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    cout << v[i].size() << " ";
    for (int j = 0; j < v[i].size(); j++) cout << A[v[i][j]] << " ";
    cout << endl;
  }
  return 0;
}
