#C14422. Modify List With Sum
Modify List With Sum
Modify List With Sum
You are given a list of n integers. Your task is to compute a new list where each element at index i is equal to the sum of all elements of the input list except the one at index i. You are not allowed to use division in your solution.
The computation should be done in linear time, i.e., in \(O(n)\) time complexity.
Example:
Input: 4 1 2 3 4 Output: 9 8 7 6
In the above example, the total sum of the list \(S = 1+2+3+4 = 10\). For each element, the result is \(S - \text{element}\). For instance, for the first element, the answer is \(10-1=9\).
inputFormat
The input is read from standard input. The first line contains an integer n (the number of elements in the list). The second line contains n space-separated integers representing the list.
\(1 \leq n \leq 10^4\) and each integer is between \(-10^5\) and \(10^5\).
outputFormat
Output a single line with n integers separated by a single space. Each integer should be the sum of all other elements except for the corresponding input element.
## sample4
1 2 3 4
9 8 7 6
</p>