#include <bits/stdc++.h>
int main() {
  int n, h = 0, k = 0, j = 0, f = 0, z = 0;
  scanf("%d", &n);
  int a[n], a1[n], a2[n], a3[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] < 0) {
      j = j + 1;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == 0) {
      a3[k] = a[i];
      k = k + 1;
    } else if (a[i] < 0) {
      if (z == 0) {
        ++z;
        a1[h] = a[i];
        h = h + 1;
        j = j - 1;
      } else if (j % 2 == 0 && z < 3) {
        a2[f] = a[i];
        f = f + 1;
        ++z;
      } else {
        a3[k] = a[i];
        k = k + 1;
        j = j - 1;
      }
      if (z > 3) {
        j = 1;
      }
    } else {
      a2[f] = a[i];
      f = f + 1;
    }
  }
  printf("%d ", h);
  for (int i = 0; i < h; i++) {
    printf("%d ", a1[i]);
  }
  printf("\n%d ", f);
  for (int i = 0; i < f; i++) {
    printf("%d ", a2[i]);
  }
  printf("\n%d ", k);
  for (int i = 0; i < k; i++) {
    printf("%d ", a3[i]);
  }
  return 0;
}
