Problems > Sum of the Others

Sum of the Others

Difficulty: 1000 3500 ms 128 MB

implementation

Replace every element with the sum of all OTHER elements and print the result.

Input: the first line has N; the second line has N integers.

Output: N integers: total − ai per position.

Constraints:

  • 1 ≤ N ≤ 105
  • -10000 ≤ ai ≤ 10000

Sample Tests

Input 1
3
1 2 3
Output 1
5 4 3
Input 2
1
5
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.