#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[101], ar2[101], ar3[101], n1 = 0, n2 = 0, n3 = 0, n;
  cin >> n;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x < 0) {
      arr[n1] = x;
      ++n1;
    } else if (x > 0) {
      ar2[n2] = x;
      ++n2;
    } else {
      ar3[n3] = x;
      ++n3;
    }
  }
  if (n2 == 0) {
    ar2[n2] = arr[n1 - 1];
    --n1;
    ++n2;
    ar2[n2] = arr[n1 - 1];
    ++n2;
    --n1;
  }
  if (n1 % 2 == 0) {
    ar3[n3] = arr[n1 - 1];
    --n1;
    ++n3;
  }
  cout << n1 << " ";
  for (int i = 0; i < n1; i++) cout << arr[i] << " ";
  cout << endl;
  cout << n2 << " ";
  for (int i = 0; i < n2; i++) cout << ar2[i] << " ";
  cout << endl;
  cout << n3 << " ";
  for (int i = 0; i < n3; i++) cout << ar3[i] << " ";
  cout << endl;
  return 0;
}
