#include <bits/stdc++.h>
int a[110], v[110];
int n1 = 0, n2 = 0, n3 = 0;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 0) v[i] = 1, n1++;
    if (a[i] > 0) v[i] = 2, n2++;
    if (a[i] == 0) v[i] = 3, n3++;
  }
  int flag = 0;
  if (n1 != 1) {
    for (int i = 0; i < n; i++) {
      if (flag == 0 && a[i] < 0) {
        v[i] = 1;
        n1 = 1;
        flag = 1;
      } else if (flag == 1 && a[i] < 0) {
        v[i] = 3;
        n3++;
      }
    }
  }
  int flag1 = 0;
  if (n2 == 0) {
    for (int i = n - 1; i >= 0; i--) {
      if ((flag1 == 0 || flag1 == 1) && (a[i] < 0)) {
        v[i] = 2;
        n2++;
        n3--;
        flag1++;
      }
    }
  }
  printf("%d ", n1);
  for (int i = 0; i < n; i++) {
    if (v[i] == 1) printf(" %d", a[i]);
  }
  printf("\n");
  printf("%d ", n2);
  for (int i = 0; i < n; i++) {
    if (v[i] == 2) printf(" %d", a[i]);
  }
  printf("\n");
  printf("%d ", n3);
  for (int i = 0; i < n; i++) {
    if (v[i] == 3) printf(" %d", a[i]);
  }
  printf("\n");
}
