🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"easy","problem_code":"MEANPROB","problem_name":"Mean Problem","problemComponents":{"constraints":"","constraintsState":false,"subtasks":"","subtasksState":false,"inputFormat":"","inputFormatState":false,"outputFormat":"","outputFormatState":false,"sampleTestCases":{}},"video_editorial_url":"","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"PYTH","5":"PYP3","6":"CS2","7":"ADA","8":"PYPY","9":"TEXT","10":"PAS fpc","11":"NODEJS","12":"RUBY","13":"PHP","14":"GO","15":"HASK","16":"TCL","17":"PERL","18":"SCALA","19":"LUA","20":"kotlin","21":"BASH","22":"JS","23":"LISP sbcl","24":"rust","25":"PAS gpc","26":"BF","27":"CLOJ","28":"R","29":"D","30":"CAML","31":"FORT","32":"ASM","33":"swift","34":"FS","35":"WSPC","36":"LISP clisp","37":"SQL","38":"SCM guile","39":"PERL6","40":"ERL","41":"CLPS","42":"ICK","43":"NICE","44":"PRLG","45":"ICON","46":"COB","47":"SCM chicken","48":"PIKE","49":"SCM qobi","50":"ST","51":"NEM"},"max_timelimit":2,"source_sizelimit":50000,"problem_author":"dpraveen_adm","problem_tester":null,"date_added":"13-12-2019","tags":{"0":"ad","1":"dpraveen_adm","2":"gw19mos","3":"icpc2019","4":"icpcgw19","5":"simple"},"problem_difficulty_level":"Simple","best_tag":"Ad Hoc","editorial_url":"https://discuss.codechef.com/problems/MEANPROB","time":{"view_start_date":1576781100,"submit_start_date":1576781100,"visible_start_date":1576781100,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=MEANPROB","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
You are given a sequence $a$ and its first $n$ elements. 

The $i$-th element of the sequence, where $i > n$ is generated by the following formula.

The $i$-th element $i > n$ would be the floor of the mean of last $n$ elements of the sequence. Formally,

$$a_i = \lfloor \frac{\sum_{k=0}^{n-1} a_{i-n+k}}{n} \rfloor$$

For example, 

$$  a_{n+1} = \lfloor \frac{a_1 + a_2 + .. + a_{n}}{n} \rfloor$$
$$ a_{n+2} = \lfloor \frac{a_2 + a_3 + .. + a_{n+1}}{n} \rfloor$$
$$ a_{n+3} = \lfloor \frac{a_3 + a_4 + .. + a_{n+2}}{n} \rfloor$$

You have to answer many queries in which you would be asked to tell some x-th element of the sequence, where $x$ would be provided in the query.

###Input:

- First line will contain $T$, number of testcases. Then the testcases follow.
- First line of each test case contains an integer $n$.
- The second of each test case contains $n$ space separated integers where $i$-th of which denotes value of $a_i$.
- The third line contains an integer $Q$ denoting the number of queries.
- Each of the next $Q$ lines contains an integer $x$, denoting that you should tell what's the $x$-th element of sequence.

###Output:
For each query, output an integer denoting the value of the corresponding element of the sequence.

###Constraints
- $1 \leq T \leq 10$
- $1 \leq n \leq 10^3$
- for $1 \leq i \leq n, 1 \leq a_i \leq 10^3$
- $1 \leq Q \leq 10^5$
- $1 \leq x \leq 10^9$

###Sample Input:
    1
    3
    2 2 3
    3
    1
    3
    4


###Sample Output:
    2
    3
    2

### Explanation
The 4th element of the array would be $$\lfloor \frac{2+2+3}{3} \rfloor = \lfloor \frac{7}{3} \rfloor = 2$$
<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>