#P3540. Squark Mass Reconstruction

    ID: 16794 Type: Default 1000ms 256MiB

Squark Mass Reconstruction

Squark Mass Reconstruction

A famous Byteotian physicist, Byteasar, is studying a new constituent of matter – squarks. These are exotic particles that never exist alone but always in pairs. Moreover, squarks of a particular kind form pairs only with squarks of different kinds.

Byteasar has established that there are \(n\) different kinds of squarks. Squarks of each kind have a unique mass, which is a positive integer multiple of some unit. He has also measured the total mass of each of the \(\binom{n}{2}\) possible pairs of squarks. According to the standard Byteotian model of physics, the mass of a pair equals the sum of the masses of the two squarks forming it.

Your task is to determine all configurations of squark masses that are consistent with these measurements.

Input Format

The input consists of two lines. The first line contains a single integer \(m\) denoting the number of measured pair sums. It is guaranteed that \(m=\binom{n}{2}\) for some integer \(n\) with \(n\ge 3\). The second line contains \(m\) positive integers separated by spaces, representing the measured pair sums in arbitrary order.

Output Format

If at least one valid configuration exists, output each configuration on a separate line. In each configuration, list the squark masses in increasing order, separated by a single space. If there is no valid configuration, output a single line containing the word “Impossible”.

Notes

Each solution must satisfy that for every pair of squarks, the sum of their masses is exactly one of the input numbers, and every input number is used exactly once.

inputFormat

The first line contains a single integer \(m\) (the number of pair sums). The second line contains \(m\) positive integers separated by spaces.

outputFormat

If there exists at least one configuration, output each valid configuration (sorted in increasing order) on a separate line. Otherwise, output the word Impossible.

sample

6
4 5 7 7 9 10
1 3 4 6