Under construction

Still being built. Things may change

Magic Orbs

Time limit1sMemory limit1024 MB

Summary
Orbs dropped on zone 1 roll right past strictly lower zones and raise the zone where they stop; report zone 1's value after each batch.
Level

Hard8 of 10

Topics
Array, Simulation, Math
Solved
No attempts yet

Problem

NN zones are arranged in a straight line. The zones are numbered 1,2,⋯ ,N1, 2, \cdots, N from left to right, and the initial value of zone ii is ViV_i.

A magic orb raises the values of zones. When an orb is dropped on zone 1, it behaves as follows.

  1. Let pp be the zone where the orb currently sits. If p<Np < N and the value of zone p+1p+1 is lower than the value of zone pp, the orb moves to zone p+1p+1. Repeat this until the orb stops moving.
  2. If the orb does not move from zone pp, add 11 to the value of that zone.

A wizard left you QQ tasks of two kinds, to be processed in order. All results accumulate. At least one task asks for the value of zone 1.

  • 1 x: Drop xx orbs onto zone 1, one at a time. Each orb finishes its movement and increases the value of the zone where it stops. Only then is the next orb dropped.
  • 2: Print the value of zone 1.

Input

The first line contains NN and QQ, separated by a space.

The second line contains the initial values V1,V2,⋯ ,VNV_1, V_2, \cdots, V_N, separated by spaces.

Each of the next QQ lines contains one task.

Output

For each task of type 2, print the value of zone 1 on its own line.

Constraints

  • All given numbers are integers.
  • 1≤N≤500 0001 \le N \le 500\,000
  • 0≤Vi≤1 000 0000 \le V_i \le 1\,000\,000 for 1≤i≤N1 \le i \le N
  • 1≤x≤1 000 0001 \le x \le 1\,000\,000
  • At least one task asks for the value of zone 1.

Examples1

  1. Example 1

    Input
    5 6
    1 3 2 5 4
    1 3
    2
    1 3
    2
    1 10
    2
    
    Expected output
    4
    5
    8