Shor the Duck has prepared plates of snacks to enjoy while watching movies! The -th plate initially contains a snack with a deliciousness value of .
You need to process queries. In the -th query, Shor will do both of the following, in order:
Eat every snack whose deliciousness is between and (inclusive).
Then, replace each eaten snack with a new snack of deliciousness .
Before processing any queries, and after each query, Shor wants you to determine the sum of deliciousness of snacks across all plates.
Formally, you are given an array of length and must process queries. Before processing any queries, print the sum of all elements in . In the -th query, update every element such that by setting , then print the updated sum of all elements in .
输入格式
Your program must read from standard input.
The first line of input contains two space-separated integers and .
The second line of input contains space-separated integers .
The following lines of input each contain three space-separated integers. The -th of these lines contains , and , describing the -th query.
输出格式
Your program must print to standard output.
The output should contain lines.
The first line of output should contain a single integer, the sum of all elements in a before all queries.
The following lines of input should each contain one integer. The -th of these lines should contain the sum of elements in a after the -th query.