P1286 Sum of Two Numbers

Description

We know that taking any two from $n$ non-negative integers and adding them yields $\frac{n(n-1)}{2}$ sums. Now, given these $\frac{n(n-1)}{2}$ sums, determine the $n$ non-negative integers.

Input Format

The input contains multiple lines. Each line is one dataset, consisting of $\frac{n(n-1)}{2} + 1$ non-negative integers separated by spaces. The first number denotes $n$ ($2 < n < 10$). The remaining $\frac{n(n-1)}{2}$ numbers are the pairwise sums. Each number does not exceed $100000$. The file ends with `EOF`.

Output Format

Output multiple lines. For each input line, output one line that contains a set of $n$ non-negative integers in ascending order, separated by single spaces. If there is no solution, output `Impossible`.

Explanation/Hint

Translated by ChatGPT 5