#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:32000000")
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000000;
const int N = 120000;
const int M = 1000;
vector<int> rec[3];
int n, arr[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i] < 0)
      rec[0].push_back(arr[i]);
    else if (arr[i] > 0)
      rec[1].push_back(arr[i]);
    else
      rec[2].push_back(arr[i]);
  }
  if (rec[1].size() == 0) {
    rec[1].push_back(rec[0][rec[0].size() - 1]);
    rec[0].pop_back();
    rec[1].push_back(rec[0][rec[0].size() - 1]);
    rec[0].pop_back();
  }
  if ((rec[0].size() & 1) == 0) {
    rec[2].push_back(rec[0][rec[0].size() - 1]);
    rec[0].pop_back();
  }
  for (int i = 0; i < 3; i++) {
    printf("%d", rec[i].size());
    for (int j = 0; j < rec[i].size(); j++) printf(" %d", rec[i][j]);
    puts("");
  }
  return 0;
}
