Pairwise Product#251

Pairwise Product

3 seconds
256 megabytes
Easy

You are given an array of integers a_1,a_2,\dots,a_n. Your task is to answer queries of the following type:

Input

The first line contains a single number (2\le n\le 2\cdot 10^5) — the size of the array .

The second line contains integers a_1,\dots,a_n (1\le a_i\le 10^9) — the elements of the array.

The third line contains a single integer (1\le q\le 2\cdot 10^5) — the number of queries.

Each of the next lines contains two integers and (1\le l<r\le n).

Output

Output lines — the answer to each query.

Examples

Example

Loading
Loading

Example 1

Loading
Loading

Example 2

Loading
Loading

Scoring

In this problem, there are conditional blocks. If your solution works correctly for certain constraints, it will receive a certain number of points. Please note that the evaluation is still in the testing phase.

  1. ( points): n\le 100, q\le100;

  2. ( points): n\le 10\,000, q\le 100;

  3. ( points): without additional constraints.