Codeforces Testing Round 2
D
Two progressions
Codeforces
2200
原题
← CE →
翻译中…

An arithmetic progression is such a non-empty sequence of numbers where the difference between any two successive numbers is constant. This constant number is called common difference. For example, the sequence 3, 7, 11, 15 is an arithmetic progression. The definition implies that any sequences whose length equals 1 or 2 are arithmetic and all sequences whose length equals 0 are non-arithmetic.

翻译中…

You are given a sequence of different integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$. You should either split it into two arithmetic progressions or find out that the operation is impossible to perform. Splitting assigns each member of the given sequence to one of two progressions, but the relative order of numbers does not change. Splitting is an inverse operation to merging.

翻译中…

Input

翻译中…

The first line contains a positive integer $*n*$ ($2 ≤ *n* ≤ 30000$), $*n*$ is the length of the given sequence. The second line contains elements of the given sequence $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($- 10^{8} ≤ *a*_{*i*} ≤ 10^{8}$). The elements of the progression are different integers.

翻译中…

Output

翻译中…

Print the required arithmetic progressions, one per line. The progressions can be positioned in any order. Each progression should contain at least one number. If there's no solution, then print "No solution" (without the quotes)in the only line of the input file. If there are several solutions, print any of them.

翻译中…

Note

翻译中…

In the second sample another solution is also possible (number three can be assigned to the second progression): 1, 2 and 3, -2, -7.

翻译中…

样例

Input #1
6
4 1 2 7 3 10
Output #1
1 2 3
4 7 10
InputCopy OutputCopy
Input #2
5
1 2 3 -2 -7
Output #2
1 2 3
-2 -7
InputCopy OutputCopy
题目信息
题号
125D
时间限制
1 s
内存限制
256 MB
标签
构造
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。