ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

2062. Ambitious Experiment

Time limit: 3.0 second
Memory limit: 128 MB
During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity. To check whether their understanding of properties of hyperspace is right, scientists have developed the following experiment.
A chain of n particles is placed in hyperspace. Positions of particles in the chain are numbered from 1 to n. Initially, ith particle has charge ai.
According to the current theory, if particle number i got special radiation with power d, oscillations would spread by hyperspace and increase by d charge of particles with numbers i, 2i, 3i and so on (i.e. with numbers divisible by i).
Using a special device, scientists can direct the radiation of the same power at a segment of adjacent particles. For example, suppose that initially there were 6 particles with zero charges, and scientists have sent radiation with power five to particles with numbers 2 and 3. Then charge of 2nd, 3rd, and 4th particles will increase to five, and charge of 6th particle will increase to ten (the oscillations will reach it twice). Charge of other particles won’t change.
Charge of particles can’t change without impact of the device.
During the experiment, the scientists plan to perform actions of the following types:
  1. Measure current charge of the particle number i.
  2. Direct radiation with power d at particles with numbers from l to r inclusive.
Your program will be given a list of performed actions. For every action of the first type the program should output value of expected charge of the particle calculated in accordance with the current theory described above.
If the expected charges of the particles coincide with charges measured during the experiment, it will turn out that scientists’ understanding of hyperspace is right, and they will be able to start building of the hyperdrives. Then inhabitants of Nibiru will finally meet their brothers from Earth in just a few years!


The first line contains a single integer n — number of particles (1 ≤ n ≤ 3 · 105).
The second line contains n integers ai separated by spaces — initial charges of the particles (0 ≤ ai ≤ 106).
The third line contains a single integer q — number of actions in the experiment (1 ≤ q ≤ 3 · 105).
Each of the following q lines contain two or four integers — a description of the next action in one of the following formats:
  • 1 i — measure current charge of the particle number i (1 ≤ in).
  • 2 l r d — direct radiation with power d at particles with numbers from l to r inclusive (1 ≤ lrn, 0 ≤ d ≤ 106).


For each query output the expected charge of the ith particle.


1 2 3
2 1 3 5
1 2
1 2 1 4 5 6
2 2 4 2
1 3
1 4
2 3 5 1
1 5
Problem Author: Alexey Danilyuk (prepared by Nikita Sivukhin)
Problem Source: Ural Regional School Programming Contest 2015