#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;

    int arr[n];
    vector<int> even;
    vector<int> odd;

    for (int i = 0; i < n; i++)
        cin >> arr[i];

    for (int i = 0; i < n; i++)
    {
        if (arr[i] % 2 == 0)
            even.push_back(arr[i]);
        else
            odd.push_back(arr[i]);
    }

    cout << even.size() << " ";
    for (int i = 0; i < even.size(); i++)
        cout << even[i] << " ";
    
    cout <<"\n" ;

    cout<< odd.size() << " ";
    for (int i = 0; i < odd.size(); i++)
        cout << odd[i] << " ";

    return 0;
}