#include <bits/stdc++.h>
using namespace std;
vector<int> v, s1, s2, s3;
void fix() {
  sort(s3.rbegin(), s3.rend());
  s2.push_back(s3.back());
  s3.pop_back();
  s2.push_back(s3.back());
  s3.pop_back();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  v.resize(n);
  for (auto &x : v) cin >> x;
  int T_idx;
  for (int i = 0; i < n; i++) {
    if (v[i] < 0) {
      s1.push_back(v[i]);
      T_idx = i;
      break;
    }
  }
  for (int i = 0; i < n; i++) {
    if (i == T_idx) continue;
    if (v[i] <= 0)
      s3.push_back(v[i]);
    else
      s2.push_back(v[i]);
  }
  if (int(s2.size()) == 0) {
    fix();
  }
  cout << s1.size() << " ";
  for (auto x : s1) cout << x << " ";
  cout << endl;
  cout << s2.size() << " ";
  for (auto x : s2) cout << x << " ";
  cout << endl;
  cout << s3.size() << " ";
  for (auto x : s3) cout << x << " ";
  cout << endl;
}
