#C14747. Transform List
Transform List
Transform List
Given a list of numbers, transform each element by squaring it and then adding 2. If the list contains any non-integer elements, output the error message ValueError: List must contain only integers.
.
The transformation function is defined as:
$$ f(x) = x^2 + 2 $$
Input is provided via standard input and output should be printed to standard output.
inputFormat
The first line contains an integer n representing the number of elements in the list. The second line contains n space-separated tokens. Each token should represent an integer.
outputFormat
If all inputs are valid integers, output the transformed list as space‐separated integers on one line. If any token is not a valid integer, output exactly:
ValueError: List must contain only integers.
4
1 2 3 4
3 6 11 18
</p>