QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#11493. Balance

Statistics

We have a balance at our disposal. The scales are in balance if and only if both pans are empty or the weights on each pan weigh the same in total. In the given set of weights one should find such two disjoint subsets that, after putting all the weights of one on one pan and all the weights of the other on the other pan, the scales are in balance. Moreover, from all the arrangements of the weights, for which the scales keep balance, one should choose that one which contains the heaviest weight possible. In case of many such solutions only one is to be given.

Task

Write a program which:

  • reads from the standard input the weights of the available weights,
  • selects two disjoint sets of the weights meeting the conditions of the task,
  • writes the result to the standard output.

Input

In the first line of the standard input there is one integer $n$, $2 \le n \le 1\,000$, equal to the number available weights. In each of the following $n$ lines there is one positive integer being the weight of one weight from the set of available weights. You may assume that all the weights weigh at most $50\,000$ in total.

Output

In the first line of the standard output you should write two nonnegative integers $p$ and $q$, separated by a single space, and denoting the numbers of weights in the first and the second set, respectively. In the second line there should be $p$ integers separated by single spaces. They should be the weights of the weights from the first set. The third line should consist of $q$ integers, separated by single spaces, equal to the weights of the weights from the second set.

Example

Input

4
1
1
2
7

Output

2 1
1 1
2

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.