Alice has a collection of sticks. Initially, she has c_ℓ sticks of length ℓ for each ℓ=1,…,N.
Alice would like to use her sticks to make some isosceles triangles. An isosceles triangle is made of two sticks of the same length, say ℓ, and a third stick with a length between 1 and 2ℓ−1 inclusive. Note that the triangles must strictly obey the triangle inequality, and equilateral triangles are okay. Each stick may be used in at most one triangle. Alice would like to know the maximum number of isosceles triangles she can make with her sticks.
There are Q events that change the collection of sticks she has. The i-th event consists of two integers ℓ_i and d_i, representing that the number of sticks of length ℓ_i changes by d_i. Note that d_i may be positive, negative, or even 0, but Alice will never have a negative number or more than 109 sticks of each length.
Your task is to determine the maximum number of isosceles triangles Alice can make after each event if she uses her sticks optimally.
The first line of input contains two space-separated integers N and Q.
The second line of input contains N space-separated integers c_1,c_2,…,c_N (0≤c_i≤109), representing Alice's initial collection.
The next Q lines of input each contain two space-separated integers ℓ_i and d_i (1≤ℓ_i≤N,−109≤d_i≤109), representing an event.
Initially and after each event, the number of sticks of length ℓ is between 0 and 109 for all ℓ=1,…,N.
Output Q lines each containing a single integer, the answer after each event.