#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> v1, v2, v3;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int k;
    scanf("%d", &k);
    if (k < 0)
      v1.push_back(k);
    else if (k > 0)
      v2.push_back(k);
    else
      v3.push_back(k);
  }
  if (v1.size() % 2 == 0 && v2.size() == 0) {
    v3.push_back(v1.back());
    v1.pop_back();
    v2.push_back(v1.back());
    v1.pop_back();
    v2.push_back(v1.back());
    v1.pop_back();
  } else if (v1.size() % 2 == 0) {
    v3.push_back(v1.back());
    v1.pop_back();
  } else if (v2.size() == 0 && v1.size() % 2 != 0) {
    v2.push_back(v1.back());
    v1.pop_back();
    v2.push_back(v1.back());
    v1.pop_back();
  }
  printf("%d ", v1.size());
  for (int i = 0; i < v1.size(); i++) printf("%d ", v1[i]);
  printf("\n");
  printf("%d ", v2.size());
  for (int i = 0; i < v2.size(); i++) printf("%d ", v2[i]);
  printf("\n");
  printf("%d ", v3.size());
  for (int i = 0; i < v3.size(); i++) printf("%d ", v3[i]);
  printf("\n");
}
