All submissions for this problem are available.
Cheetah forgot his tiffin one day. Now he has to go to the canteen to have lunch.Since Money is no issue to him and he is not able to decide what he wants to eat he decides that he would eat one item from each section in the menu (juice, dosa, pizza etc..) among n sections. Since by this time Neel has already finished his lunch he decides to calculate various combinations of things Cheetah can order. At this time Nishchith comes and tries to fiddle with Neel and asks him q queries to calculate combinations if the menu is reduced to few continuous sections from l to r. Each section has a[i] items. Since Neel is inherently lazy, help him tackle all queries given by Nishchith. Now since answer can be large report the answer in modulo 109+7.
First line contains single integer n denoting number of sections in the menu.
Next line contains n integer ith of it denoting items available in each section.
Next line contains single integer q denoting number of queries.
Next q lines contain two integer l and r.
For each query q print no of combination in a newline.
10 20 30 40
for the query1
the total possibility is (10 × 20 × 30 × 40)mod(109+7)=240000
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6|
Fetching successful submissions