#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, c1 = 0, c2 = 0, c3 = 0;
  cin >> n;
  int a[n];
  vector<int> v, v1, v2;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      v.push_back(a[i]);
    } else if (a[i] > 0) {
      v1.push_back(a[i]);
    }
  }
  if (v.size() % 2 != 0) {
    cout << "1"
         << " " << v.at(0) << "\n";
    c1 = v.size() - 1;
    c2 = v1.size();
    cout << c1 + c2 << " ";
    for (i = 1; i <= c1; i++) {
      cout << v.at(i) << " ";
    }
    for (i = 0; i < c2; i++) {
      cout << v1.at(i) << " ";
    }
    cout << "\n";
    cout << "1"
         << " "
         << "0";
  } else {
    cout << "1"
         << " " << v.at(0) << "\n";
    c2 = v1.size();
    c1 = v.size() - 1;
    if (c2 == 0) {
      cout << c2 + c1 - 1 << " ";
      for (i = 1; i < c1; i++) {
        cout << v.at(i) << " ";
      }
      cout << "\n";
      cout << "2"
           << " "
           << "0"
           << " " << v.at(v.size() - 1);
    } else if (c2 != 0) {
      cout << c2 << " ";
      for (i = 0; i < c2; i++) {
        cout << v1.at(i) << " ";
      }
      cout << "\n";
      cout << c1 + 1 << " "
           << "0"
           << " ";
      for (i = 1; i <= c1; i++) {
        cout << v.at(i) << " ";
      }
    }
  }
}
