#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x = 0, y = 0, z = 0, k = 0;
  cin >> n;
  int a[n], b[n], c[1], d[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) {
      b[x] = 0;
      x++;
    }
    if (a[i] < 0) {
      c[0] = a[i];
      z = i;
      k++;
    }
    if (a[i] > 0) {
      d[y] = a[i];
      y++;
    }
  }
  if (k == 2) {
    for (int i = 0; i < n; i++) {
      if (a[i] < 0 && i != z) {
        b[x] = a[i];
        x++;
      }
    }
  } else if (k % 2 == 0) {
    for (int i = 0; i < n; i++) {
      if (a[i] < 0 && i != z && k > 3) {
        b[x] = a[i];
        x++;
        k--;
      } else if (a[i] < 0 && i != z && k <= 3) {
        d[y] = a[i];
        y++;
      }
    }
  } else if (k % 2 != 0) {
    for (int i = 0; i < n; i++) {
      if (a[i] < 0 && i != z) {
        d[y] = a[i];
        y++;
      }
    }
  }
  cout << 1 << " " << c[0] << endl;
  cout << y << " ";
  for (int i = 0; i < y; i++) {
    cout << d[i] << " ";
  }
  cout << endl;
  cout << x << " ";
  for (int i = 0; i < x; i++) {
    cout << b[i] << " ";
  }
  return 0;
}
