#include <bits/stdc++.h>
using namespace std;
template <class T1>
void deb(T1 e1) {
  cout << e1 << "\n";
}
template <class T1, class T2>
void deb(T1 e1, T2 e2) {
  cout << e1 << " " << e2 << "\n";
}
template <class T1, class T2, class T3>
void deb(T1 e1, T2 e2, T3 e3) {
  cout << e1 << " " << e2 << " " << e3 << "\n";
}
template <class T1, class T2, class T3, class T4>
void deb(T1 e1, T2 e2, T3 e3, T4 e4) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << "\n";
}
template <class T1, class T2, class T3, class T4, class T5>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << "\n";
}
template <class T1, class T2, class T3, class T4, class T5, class T6>
void deb(T1 e1, T2 e2, T3 e3, T4 e4, T5 e5, T6 e6) {
  cout << e1 << " " << e2 << " " << e3 << " " << e4 << " " << e5 << " " << e6
       << "\n";
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> minus, plus, zero;
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (temp < 0)
      minus.push_back(temp);
    else if (temp > 0)
      plus.push_back(temp);
    else
      zero.push_back(0);
  }
  int min_size = minus.size();
  if (min_size % 2 == 0) zero.push_back(minus[--min_size]);
  if (plus.size() == 0) {
    plus.push_back(minus[--min_size]);
    plus.push_back(minus[--min_size]);
  }
  cout << min_size << " ";
  for (int i = 0; i < min_size; i++) {
    cout << minus[i] << " ";
  }
  cout << "\n";
  cout << plus.size() << " ";
  for (int i = 0; i < plus.size(); i++) {
    cout << plus[i] << " ";
  }
  cout << "\n";
  cout << zero.size() << " ";
  for (int i = 0; i < zero.size(); i++) cout << zero[i] << " ";
  cout << "\n";
  return 0;
}
