#P1715C. Monoblock
Monoblock
No submission language available for this problem.
Description
Stanley has decided to buy a new desktop PC made by the company "Monoblock", and to solve captcha on their website, he needs to solve the following task.
The awesomeness of an array is the minimum number of blocks of consecutive identical numbers in which the array could be split. For example, the awesomeness of an array
- is ;
- is , as it could be split into blocks and ;
- is 3, as it could be split into blocks , , and .
You are given an array of length . There are queries of two integers , . A query , means that from now on the -th element of the array is equal to .
After each query print the sum of awesomeness values among all subsegments of array . In other words, after each query you need to calculate where is the awesomeness of the array .
In the first line you are given with two integers and ().
The second line contains integers () — the array .
In the next lines you are given the descriptions of queries. Each line contains two integers and (, ).
Print the answer to each query on a new line.
Input
In the first line you are given with two integers and ().
The second line contains integers () — the array .
In the next lines you are given the descriptions of queries. Each line contains two integers and (, ).
Output
Print the answer to each query on a new line.
Samples
Note
After the first query is equal to , and the answer is because we can split each of the subsegments the following way:
- : , 1 block;
- : , 2 blocks;
- : , 2 blocks;
- : , 3 blocks;
- : , 4 blocks;
- : , 1 block;
- : , 1 block;
- : , 2 blocks;
- : , 3 blocks;
- : , 1 block;
- : , 2 blocks;
- : , 3 blocks;
- : , 1 block;
- : , 2 blocks;
- : , 1 block;