The Live Forecast

You’re monitoring a live sensor dashboard. Readings arrive one by one, and you need to make a quick forecast before each new reading appears.

Your rule is simple: predict the next value using the average of all values seen so far.

The first line of the input contains a single integer n - the size of the initial historical (training) set. The second line contains n space-separated floating-point numbers.

The third line contains a single integer m - the number of incoming live readings. Each of the next m lines contains one number - the true reading that arrives at that moment.

For each of the m moments, print the current mean of all values seen so far (the n training values plus any previous live readings) each on a separate line.

Input

Output

3
10 20 30
4
50
10
40
30

20
27.5
24
26.66666666666666

1
100
3
100
100
100

100
100
100

2
1.5 2.5
2
3.5
0.5

2
2.5

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue