#K78977. Array Sum Exclusion
Array Sum Exclusion
Array Sum Exclusion
Given an array \(A\) of \(n\) integers, construct an array \(B\) such that for each index \(i\), \(B_i = \sum_{\substack{j=0 \\ j \neq i}}^{n-1} A_j\). In other words, each element of \(B\) is the sum of all elements of \(A\) except the one at that index. You are not allowed to use division operations.
This problem tests your ability to perform basic arithmetic and work with arrays. Consider how you might compute the total sum of the array once, and then subtract each element from this total to form the output array.
inputFormat
The first line contains a single integer \(n\), the number of elements in the array \(A\). The second line contains \(n\) space-separated integers representing the elements of \(A\).
outputFormat
Output a single line containing \(n\) space-separated integers representing the array \(B\), where \(B_i = \sum_{j=0, j\neq i}^{n-1} A_j\) for \(0 \leq i < n\).
## sample5
1 2 3 4 5
14 13 12 11 10