#include <bits/stdc++.h>
using namespace std;
int a[104];
int cnt, ans;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (int i = 1; i < n; i++) {
    if (a[i] > 0) cnt++;
    if (a[i] < 0) ans++;
  }
  if (cnt == 0) {
    cout << 1 << " " << a[0] << endl;
    if (ans % 2 != 0) {
      cout << ans - 1 << " ";
      for (int i = 1; i <= ans - 1; i++) {
        cout << a[i] << " ";
      }
      cout << endl;
      cout << 2 << " " << 0 << " " << a[ans];
    } else {
      cout << ans << " ";
      for (int i = 1; i < n; i++) {
        if (a[i] < 0) cout << a[i] << " ";
      }
      cout << endl;
      cout << 1 << " " << 0;
    }
  } else {
    cout << 1 << " " << a[0] << endl;
    cout << cnt << " ";
    for (int i = 1; i < n; i++) {
      if (a[i] > 0) cout << a[i] << " ";
    }
    cout << endl;
    cout << ans + 1 << " ";
    for (int i = 1; i < n; i++) {
      if (a[i] < 0) cout << a[i] << " ";
    }
    cout << 0;
  }
  return 0;
}
