#include <bits/stdc++.h>
using namespace std;
void Shellsort(int A[], int N) {
  int i, j, Increment;
  int Tmp;
  for (Increment = N / 2; Increment > 0; Increment /= 2)
    for (i = Increment; i < N; i++) {
      Tmp = A[i];
      for (j = i; j >= Increment; j -= Increment)
        if (Tmp < A[j - Increment])
          A[j] = A[j - Increment];
        else
          break;
      A[j] = Tmp;
    }
}
int main() {
  int n, i, flag1 = 0, flag2 = 0, flag3 = 0, sum = 0;
  int a[101];
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > 0) sum++;
  }
  Shellsort(a, n);
  if (sum == 0) {
    printf("1 %d\n", a[0]);
    printf("2 %d %d\n", a[1], a[2]);
    printf("%d", n - 3);
    for (i = 3; i < n; i++) printf(" %d", a[i]);
  } else {
    printf("1 %d\n", a[0]);
    printf("1 %d\n", a[n - 1]);
    printf("%d", n - 2);
    for (i = 1; i < n - 1; i++) printf(" %d", a[i]);
  }
  return 0;
}
