Given an array of integers, you must answer a number of queries. Each query consists of a single integer, , and is performed as follows:
- Add to each element of the array, permanently modifying it for any future queries.
- Find the absolute value of each element in the array and print the sum of the absolute values on a new line.
Tip: The Input/Output for this challenge is very large, so you'll have to be creative in your approach to pass all test cases.
Function Description
Complete the playingWithNumbers function in the editor below. It should return an array of integers that represent the responses to each query.
playingWithNumbers has the following parameter(s):
- arr: an array of integers
- queries: an array of integers
Input Format
The first line contains an integer the number of elements in .
The second line contains space-separated integers .
The third line contains an integer , the number of queries.
The fourth line contains space-separated integers where .
Constraints
- , where .
- , where
Output Format
For each query, print the sum of the absolute values of all the array's elements on a new line.
Sample Input
3
-1 2 -3
3
1 -2 3
Sample Output
5
7
6
Explanation
Query 0:
Array:
The sum of the absolute values of the updated array's elements is .
Query 1:
Array:
The sum of the absolute values of the updated array's elements is .
Query 2:
Array:
The sum of the absolute values of the updated array's elements is .