#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> pos, neg, zero;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x < 0)
      neg.push_back(x);
    else if (x > 0)
      pos.push_back(x);
    else
      zero.push_back(x);
  }
  if (neg.size() % 2 == 0) {
    zero.push_back(neg[0]);
    neg.erase(neg.begin());
  }
  if (pos.size() == 0) {
    pos.push_back(neg[0]);
    pos.push_back(neg[1]);
    neg.erase(neg.begin(), neg.begin() + 2);
  }
  cout << neg.size() << " ";
  for (auto x : neg) cout << x << " ";
  cout << endl;
  cout << pos.size() << " ";
  for (auto x : pos) cout << x << " ";
  cout << endl;
  cout << zero.size() << " ";
  for (auto x : zero) cout << x << " ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
}
