Problem Preparation

Maintain an array under point increments and decrements, and after each update answer the sum of ceil(t_i / k) for a given k.

Medium7MathPrefix sumArrayImplementationInterviewNo attempts yetTime limit2sMemory limit256 MB

Problem

Andrew has written nn programming problems for a contest and now he plans to prepare them. He estimates that preparing problem ii takes tit_i minutes in total. Andrew wants to invite his friends to share the work.

He does not know how many friends will agree to help, but he wants to split the work fairly. So for problem ii he picks an integer xix_i, and every friend who helps spends xix_i minutes on that problem. Problem ii is completely prepared once the total time his friends spend on it is at least tit_i minutes. With kk friends helping, xix_i is the smallest integer that satisfies k×xitik \times x_i \ge t_i.

Whenever Andrew realizes that he misjudged the difficulty of a problem, he increases or decreases tit_i by 1.

You are given the initial estimates tit_i. Process mm queries in the given order. Each query is one of the following.

  • 1 i: Andrew increases tit_i by 1.
  • 2 i: Andrew decreases tit_i by 1.
  • 3 k: Andrew wants to know how many minutes one friend spends preparing all nn problems when kk friends help.

Input

The first line contains two integers nn and mm, the number of problems and the number of queries. (1n,m1051 \le n, m \le 10^5)

The second line contains nn integers t1,t2,,tnt_1, t_2, \dots, t_n, where tit_i is Andrew's initial estimate for problem ii. (1ti5×1051 \le t_i \le 5 \times 10^5)

Each of the next mm lines contains one query as two integers qq and vv. If qq is 1, then tvt_v increases by 1. If qq is 2, then tvt_v decreases by 1. In both cases 1vn1 \le v \le n. If qq is 3, then you must report the time one friend spends when vv friends help. In this case 1v5×1051 \le v \le 5 \times 10^5.

After every query all values of tit_i stay between 1 and 5×1055 \times 10^5.

Output

For every query with qq equal to 3, print on its own line the total time one friend spends preparing all nn problems, that is x1+x2++xnx_1 + x_2 + \dots + x_n.