#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a[3];
  int n, ans[150], pos = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> ans[i];
    if (ans[i] < 0) pos++;
  }
  if (pos % 2 == 0) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (ans[i] < 0 && cnt == 0) {
        a[0].push_back(ans[i]);
        cnt++;
      } else if (ans[i] < 0 && cnt == 1) {
        a[2].push_back(ans[i]);
        cnt++;
      } else if (ans[i] == 0)
        a[2].push_back(ans[i]);
      else
        a[1].push_back(ans[i]);
    }
  } else {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (ans[i] < 0 && cnt == 0) {
        a[0].push_back(ans[i]);
        cnt++;
      } else if (ans[i] == 0)
        a[2].push_back(ans[i]);
      else
        a[1].push_back(ans[i]);
    }
  }
  for (int i = 0; i < 3; i++) {
    cout << a[i].size() << ' ';
    for (int j = 0; j < a[i].size(); j++) cout << a[i][j] << ' ';
    cout << endl;
  }
  return 0;
}
