Kozak Vus and NSD#10447

Kozak Vus and NSD

2 seconds
256 megabytes
Medium

Cossack Vus has an array consisting of integers. He learns about another array , which also has integers, but he doesn't know the values of . To determine the array , Vus can perform the following operation any number of times:

Vus wants you to find the minimum number of coins needed to determine the array .

Additionally, Vus will change a certain number a_i to a total of times. After each change, you need to find the minimum number of coins required for the updated array.

Input

The first line contains two integers and (1 \leq n \leq 10^5, 0 \leq q \leq 10^5) — the number of elements in the array and the number of changes to the array.

The second line contains integers a_1, a_2, ..., a_n (1 \leq a_i \leq 10^9) — the elements of the array.

The next lines each contain two integers and (1 \leq i \leq n, 1 \leq x \leq 10^9) — the index of the element in the array that is changed and the new value it is changed to.

Output

Output q + 1 numbers — for each version of the array , find the minimum number of coins needed to determine the array .

The first number is the answer for the initial array .

The next numbers are the answers for each update of the array.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading

Scoring

  1. ( points): n \le 10^2, q = 0;

  2. ( points): n \le 10^3, q = 0;

  3. ( points): q = 0;

  4. ( points): q \leq 100;

  5. ( points): q \leq 500;

  6. ( points): q \leq 10000;

  7. ( points): no additional constraints.