#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int v[105];
  bool flag[105];
  while (cin >> n) {
    int neg_idx = -1;
    int pos_idx = -1;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] < 0 && neg_idx == -1)
        neg_idx = i;
      else if (v[i] > 0 && pos_idx == -1)
        pos_idx = i;
    }
    memset(flag, 0, sizeof(flag));
    cout << "1 " << v[neg_idx] << '\n';
    flag[neg_idx] = true;
    if (pos_idx != -1) {
      cout << "1 " << v[pos_idx] << '\n';
      flag[pos_idx] = true;
    } else {
      cout << 2;
      int num = 2;
      for (int i = 0; num > 0 && i < n; i++) {
        if (i != neg_idx && v[i] < 0) {
          cout << ' ' << v[i];
          flag[i] = true;
          num--;
        }
      }
      cout << '\n';
    }
    if (pos_idx != -1)
      cout << n - 2;
    else
      cout << n - 3;
    for (int i = 0; i < n; i++)
      if (!flag[i]) cout << ' ' << v[i];
    cout << '\n';
  }
  return 0;
}
