Chocolate Distribution - I

0

0 votes
Arrays, Implementaion
Problem

Given N boxes labelled 1 to N each box having non negative amount of chocolates. You are assigned with a task of distributing more chocolates in the boxes. You have infinite supply of chocolates.

You have been given Q queries. In each query you will be given three integers L, R and V. In each query you have to add V chocolates each, to all the boxes between L to R (L and R inclusive).

You have to calculate the final amount of chocolates in each box after processing all the queries.

Input

First line contains an integer N denoting the number of chocolate boxes.

Second line contains N non ngetaive integers denoting the number of chocolates in each box.

Third line contains Q denoting the number of queries.

Next Q lines contain Li, Ri, Vi for each ith query.

Output

Print the total amount of chocolates each box has after performing all the queries.

Constraints

1N106

1Q106

1L,R,N

1V,BOX[i]106

Author :Mohit Tarani

Sample Input
7
10 12 5 2 1 9 30
3
1 3 5
2 4 3
1 5 6
Sample Output
21 26 19 11 7 9 30 
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

After first query the state of the array is

15, 17, 10, 2, 1, 9, 30

After second query the state of the array is

15, 20, 13, 5, 1, 9, 30

After third query the state of the array is

21, 26, 19, 11, 7, 9, 30

Contributers:
Editor Image

?