#C14630. Differences from Minimum
Differences from Minimum
Differences from Minimum
You are given a list of integers. Your task is to compute a new list where each element is the difference between the corresponding element in the original list and the smallest element in that list. In other words, if the original list is \(a_1, a_2, \dots, a_n\) and \(m = \min\{a_1, a_2, \dots, a_n\}\), then the result list is \( (a_1 - m), (a_2 - m), \dots, (a_n - m) \). Note that all differences are non-negative.
If the list is empty, output an error message: "The list should not be empty.". Also, if any element in the list is not an integer, output an error message: "The list should contain only integers.".
inputFormat
The input is read from stdin
and has the following format:
- The first line contains a single integer \(n\), which represents the number of elements in the list.
- The second line contains \(n\) space-separated tokens. These tokens are expected to be integers.
If \(n \le 0\), or if any token is not a valid integer, output the corresponding error message.
outputFormat
Print to stdout
a single line containing the computed list of differences as space-separated integers. If an error occurs due to invalid input or an empty list, print the corresponding error message.
4
1 2 3 4
0 1 2 3