**Trash Problem SOLUTION**

**Trash Problem SOLUTION**

Vova chose to tidy up his room. The room can be spoken to as the facilitate pivot OX. There are n heaps of waste in the room, arrange of the I-th heap is the whole number pi. All heaps have various directions.

How about we characterize a complete cleanup as the accompanying cycle. The objective of this cycle is to gather all the heaps in close to two distinctive x facilitates. To accomplish this objective, Vova can do a few (perhaps, zero) moves. During one move, he can pick some x and move all heaps from x to x+1 or x−1 utilizing his brush. Note that he can’t pick what number of heaps he will move.

Additionally, there are two kinds of questions:

0 x — eliminate a heap of waste from the facilitate x. It is ensured that there is a heap in the facilitate x as of now.

1 x — add a heap of refuse to the arrange x. It is ensured that there is no heap in the organize x as of now.

Note that it is conceivable that there are zero heaps of rubbish in the room at some second.

Vova needs to know the base number of moves he can spend on the off chance that he needs to do an absolute cleanup before any inquiries. He likewise needs to know this number of moves in the wake of applying each inquiry. Inquiries are applied in the provided request. Note that the all out cleanup doesn’t really occur and doesn’t change the condition of heaps. It is just used to figure the quantity of moves.

For better seeing, it would be ideal if you read the Notes segment beneath to see a clarification for the principal model.

Info

The principal line of the info contains two numbers n and q (1≤n,q≤105) — the quantity of heaps in the room before all questions and the quantity of inquiries, individually.

The second line of the info contains n particular numbers p1,p2,… ,pn (1≤pi≤109), where pi is the organize of the I-th heap.

The following q lines depict questions. The I-th inquiry is portrayed with two whole numbers ti and xi (0≤ti≤1;1≤xi≤109), where ti is 0 on the off chance that you have to eliminate a heap from the arrange xi and is 1 in the event that you have to add a heap to the organize xi. It is ensured that for ti=0 there is such heap in the current arrangement of heaps and for ti=1 there is no such heap in the current arrangement of heaps.

Yield

Print q+1 whole numbers: the base number of moves Vova needs to do an absolute cleanup before the primary question and after every one of q inquiries.

Models

input

5 6

1 2 6 8 10

1 4

1 9

0 6

0 10

1 100

1 50

output

5

7

7

5

4

8

49

input

5 8

5 1 2 4 3

0 1

0 2

0 3

0 4

0 5

1 1000000000

1

1 500000000

output

3

2

1

0

0

0

0

0

499999999

Note

Think about the primary model.

At first, the arrangement of heaps is [1,2,6,8,10]. The appropriate response before the primary question is 5 since you can move all heaps from 1 to 2 with one move, all heaps from 10 to 8 with 2 moves and all heaps from 6 to 8 with 2 moves.

After the main inquiry, the set becomes [1,2,4,6,8,10]. At that point the appropriate response is 7 since you can move all heaps from 6 to 4 with 2 moves, all heaps from 4 to 2 with 2 moves, all heaps from 2 to 1 with 1 move and all heaps from 10 to 8 with 2 moves.

After the subsequent question, the arrangement of heaps becomes [1,2,4,6,8,9,10] and the appropriate response is the equivalent (and the past grouping of moves can be applied to the current arrangement of heaps).

After the third question, the arrangement of heaps becomes [1,2,4,8,9,10] and the appropriate response is 5 since you can move all heaps from 1 to 2 with 1 move, all heaps from 2 to 4 with 2 moves, all heaps from 10 to 9 with 1 move and all heaps from 9 to 8 with 1 move.

After the fourth question, the set becomes [1,2,4,8,9] and the appropriate response is nearly the equivalent (the past grouping of moves can be applied without moving heaps from 10).

After the fifth inquiry, the set becomes [1,2,4,8,9,100]. You can move all heaps from 1 and further to 9 and keep 100 at its place. So the appropriate response is 8.

After the 6th inquiry, the set becomes [1,2,4,8,9,50,100]. The appropriate response is 49 and can be gotten with nearly similar grouping of moves as after the past question. The main distinction is that you have to move all heaps from 50 to 9 as well.

**We are Live Join Us**

**Check Your Mails**