#include <bits/stdc++.h>
using namespace std;
struct node
{
int data;
struct node *next;
};
struct node *crea(int n)
{
int i;
struct node *head, *p;
head = (struct node *)malloc(sizeof(struct node));
head -> next = NULL;
for(i = 0; i < n; i ++)
{
p = (struct node *)malloc(sizeof(struct node));
scanf("%d", &p -> data);
p -> next = head -> next;
head -> next = p;
}
return head;
};
struct node *spilt(struct node *head)
{
struct node *head1, *p, *q;
int a = 0, b = 0;
head1 = (struct node *)malloc(sizeof(struct node));
head1 -> next = NULL;
p = head -> next;
head -> next = NULL;
q = p -> next;
while(p)
{
if(p -> data % 2 == 0)
{
p -> next = head -> next;
head -> next = p;
a++;
}
else
{
p -> next = head1 -> next;
head1 -> next = p;
b ++;
}
p = q;
if(q)
q = q -> next;
}
printf("%d %d
",a,b);
return head1;
};
int main()
{
int n;
struct node *head, *p, *q, *head1;
scanf("%d", &n);
head = crea(n);
head1 = spilt(head);
p = head -> next;
while(p!=NULL)
{
if(p -> next != NULL)printf("%d ", p -> data);
else printf("%d
", p ->data);
p = p -> next;
}
q = head1 -> next;
while(q!=NULL)
{
if(q -> next != NULL)printf("%d ", q -> data);
else printf("%d
",q -> data);
q = q -> next;
}
return 0;
}