The Halfway Fix

Your lab has a temperature sensor that’s a bit noisy. To stabilize the readings, the lab uses a simple trick: it blends each new reading with the long-term average, pulling the value halfway toward that average.

Today, you’re asked to build a tiny predictor that follows this rule.

First, you’ll learn the sensor’s long-term behavior from past data. You should compute the global mean M of the historical readings. Then, for each incoming reading r, output the adjusted prediction:

The first line of the input contains a single integer n - the number of past readings.

The second line contains n space-separated integers representing the reading values of the sensor.

The third line contains a single integer q - the number of incoming readings to adjust.

The fourth line contains q numbers (integers or decimals) - the incoming readings.

The program should print one adjusted value per line, in order.

Input

Output

4
10 12 11 13
3
20 8 11

15.75
9.75
11.25

5
5 5 5 5 5
3
7 5 3

6
5
4

4
10 9 9 8
4
10 8 6 12

9.5
8.5
7.5
10.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