#K52777. Unique Sums from Two Distinct Elements

    ID: 29385 Type: Default 1000ms 256MiB

Unique Sums from Two Distinct Elements

Unique Sums from Two Distinct Elements

This problem requires you to compute all the unique sums that can be generated by adding two distinct elements from a given list of integers. For a list \( a_1, a_2, \dots, a_N \), consider all pairs \( (a_i, a_j) \) such that \( i < j \) and compute \( a_i + a_j \). Your task is to output all distinct sums sorted in non-decreasing order.

If no such pair exists, output nothing.

inputFormat

The input is provided via standard input (stdin) and consists of two lines:

  • First line: An integer \( N \) representing the number of elements.
  • Second line: \( N \) space-separated integers representing the elements of the list.

outputFormat

Print the unique sums obtained by adding every pair of distinct elements, with each sum on a new line, sorted in non-decreasing order. If no valid pair exists, output nothing.

## sample
4
1 2 3 4
3

4 5 6 7

</p>