Chef Datta likes betting in Indian Premier League very much.
He has 10000 rupees. Today the match is between team A and team B. The winning probability of team A is P_{A}, and hence winning probability of team B is P_{B} = 1 − P_{A}. 

Datta is free to bet any integral amount of money on any of the two teams as long as the total amount of money bet is at most 10000 rupees.
Help him know the expected amount of money he will eventually have if today he places his bet(s) optimally.

------ Rules of the game: ------ 

If team X with winning probability P_{X} actually wins and someone bets M rupees on this team, he will gain (2*(1−P_{X})) * M rupees.
If team X with winning probability P_{X} actually loses and someone bets N rupees on this team, he will just lose N rupees.

------ Input ------ 

First line contains single integer T, the number of testcases. Then T lines follow, each line contains P_{A} the probability that team A wins.

------ Output ------ 

For each test case output single line containing the expected amount of money Datta will eventually have today if he places his bet(s) optimally. Your answer will be accepted if the absolute error is less than 10^{−6}.

------ Constraints ------ 

$1 ≤ T ≤ 100001 (10^{5}+1)$
$0.0 ≤  P_{A} ≤ 1.0$
$P_{A} has at most 5 digits after the decimal point.$
----- Sample Input 1 ------ 
1
0.510
----- Sample Output 1 ------ 
10098

------ Explanation 0 ------ 

Look at the following situation:

If chef  Datta bets 6,000 on team A and 4,000 on team B, the expected amount of money he will have after the bet is settled is 10,018. Apparently that is not the best he can do ;)

Source: codechef | Difficulty: MEDIUM
Tags: Probability


Solutions:
T = int(input())
for i in range(T):
	p = float(input())
	sum1 = 0
	sum2 = 0
	sum3 = 0
	sum4 = 0
	if p < 0.5:
		p = 1 - p
		m1 = p * 10000
		m2 = (1 - p) * 10000
		sum1 += m1 + 2 * (1 - p) * m1
		sum2 += m2 + 2 * (1 - p) * m2
		sum3 += m1 + 2 * p * m1
		sum4 += m2 + 2 * p * m2
		if sum1 + sum2 > sum3 + sum4:
			print(max(sum3, sum4))
		else:
			print(max(sum1, sum2))
	elif p == 1:
		print(10000)
	else:
		m1 = p * 10000
		m2 = (1 - p) * 10000
		sum1 += m1 + 2 * (1 - p) * m1
		sum2 += m2 + 2 * (1 - p) * m2
		sum3 += m1 + 2 * p * m1
		sum4 += m2 + 2 * p * m2
		if sum1 + sum2 > sum3 + sum4:
			print(max(sum3, sum4))
		else:
			print(max(sum1, sum2))


for _ in range(int(input())):
	p = float(input())
	res = 10000
	if p > 0.5:
		res = 10000 + 10000 * (1 - p) * (2 * p - 1)
	else:
		res = 10000 + 10000 * p * (1 - 2 * p)
	print(res)


for j in range(int(input())):
	a = float(input())
	b = 1 - a
	ma = a * 10000
	mb = (1 - a) * 10000
	sum = 0
	if a > b:
		sum += 2 * b * ma + ma
	else:
		sum += 2 * a * mb + mb
	print(sum)


T = int(input())
for i in range(T):
	p = float(input())
	sum = 0
	if p < 0.5:
		m = (1 - p) * 10000
		sum += m + 2 * p * m
	elif p == 1:
		sum += 10000
	else:
		m = p * 10000
		sum += m + 2 * (1 - p) * m
	print(sum)


for _ in range(int(input())):
	n = float(input())
	m = 1 - n
	count = 10000 * (3.0 * m - 2 * m * m)
	if 1 - 2 * m > 0:
		count += (1 - 2 * m) * 10000
	print(count)


for tc in range(int(input())):
	x = float(input())
	n = max(x, 1 - x)
	ans = 2 * (1 - n) * (10000 * n) + 10000 * n
	print('{:.6f}'.format(ans))


t = int(input())
for _ in range(t):
	n = float(input())
	gain = 2 * 10000 * n * (1 - n)
	loss = min(n, 1 - n)
	loss = 10000 * loss
	print(10000 + gain - loss)


for i in range(int(input())):
	pa = float(input())
	res = 10000
	if pa > 0.5:
		res = 10000 + 10000 * (1 - pa) * (2 * pa - 1)
	else:
		res = 10000 + 10000 * pa * (1 - 2 * pa)
	print(res)


t = int(input())
for _ in range(t):
	prob = float(input())
	start = 10000
	if prob < 0.5:
		prob = 1 - prob
	gain = start * 2 * (1 - prob) * prob
	loss = start * (1 - prob)
	print(start + gain - loss)


t = int(input())
for i in range(t):
	prob = float(input())
	if prob > 0.5:
		profit = (1 - prob) * 10000 * (2 * prob - 1)
	else:
		profit = (1 - 2 * prob) * 10000 * prob
	print(10000 + profit)


t = int(input())
for _ in range(t):
	pa = float(input())
	if pa >= 0.5:
		print(10000 + 10000 * (1 - pa) * (2 * pa - 1))
	else:
		print(10000 + 10000 * pa * (1 - 2 * pa))


for i in range(int(input())):
	n = float(input())
	x = 1 - n
	if n > x:
		print(2 * (1 - n) * n * 10000 + n * 10000)
	else:
		print(2 * (1 - x) * x * 10000 + x * 10000)


for _ in range(int(input())):
	Pa = float(input())
	if Pa > 0.5:
		print((2 * Pa - 1) * 10000 * (1 - Pa) + 10000)
	else:
		print((1 - 2 * Pa) * 10000 * Pa + 10000)


t = int(input())
for _ in range(t):
	p = float(input())
	x = 10000
	p = max(p, 1 - p)
	g = x * 2 * (1 - p) * p
	l = x * (1 - p)
	print(x + g - l)


n = 10000

def gain(p):
	a = max(p, 1 - p)
	b = min(p, 1 - p)
	return 2 * n * a * b

def lose(p):
	a = max(p, 1 - p)
	b = min(p, 1 - p)
	return n * b
for _ in range(int(input())):
	p = float(input())
	print(n + gain(p) - lose(p))


for _ in range(int(input())):
	Pa = float(input())
	Pb = 1 - Pa
	if Pa >= Pb:
		print(10000 + 10000 * (1 - Pa) * (2 * Pa - 1))
	else:
		print(10000 + 10000 * (1 - Pb) * (2 * Pb - 1))


for _ in range(int(input())):
	p = float(input())
	max_amount = float('-inf')
	if int(p) == 1:
		print(10000)
		continue
	if p == 0:
		print(10000)
		continue
	amount = 10000 * p
	max_amount = max(max_amount, amount + amount * (2 * (1 - p)))
	amount = 10000 * (1 - p)
	max_amount = max(max_amount, amount + amount * (2 * p))
	print(max_amount)


for _ in range(int(input())):
	pw = float(input())
	pl = 1 - pw
	p = max(pw, pl)
	l = 10000 * (1 - p)
	w = 10000 * 2 * (1 - p) * p
	print(10000 - l + w)


for i in range(int(input())):
	p = float(input())
	if p >= 0.5:
		print(10000 + 10000 * (1 - p) * (2 * p - 1))
	else:
		print(10000 + 10000 * p * (1 - 2 * p))


import os, sys, io, math
from re import *
from math import *
from array import *
from heapq import *
from bisect import *
from functools import *
from itertools import *
from statistics import *
from collections import *
I = lambda : [*map(int, sys.stdin.readline().split())]
IP = lambda : map(int, input().split())
IS = lambda : input()
IN = lambda : int(input())
IF = lambda : float(input())

def f():
	n = IF()
	s = 10000
	if n < 0.5:
		n = 1 - n
	g = s * 2 * (1 - n) * n
	l = s * (1 - n)
	return s + g - l
for _ in range(IN()):
	print(f())


for _ in range(int(input())):
	px = float(input())
	n = max(px, 1 - px)
	ans = 2 * (1 - n) * (10000 * n) + 10000 * n
	print('{:.6f}'.format(ans))


for _ in range(int(input())):
	p = float(input())
	if p >= 1 - p:
		print(p * 10000 + 2 * (1 - p) * (p * 10000))
	else:
		print((1 - p) * 10000 + 2 * p * ((1 - p) * 10000))


for _ in range(int(input())):
	p = float(input())
	C = 10000
	if p < 0.5:
		m = (1 - p) * C
		ans = m + 2 * p * m
	elif p == 1:
		ans = C
	else:
		m = p * C
		ans = m + 2 * (1 - p) * m
	print(ans)


def soln(pa):
	win_prob = max(pa, 1 - pa)
	bet = 10000
	return win_prob * bet + 2 * win_prob * (1 - win_prob) * bet
for _ in range(int(input())):
	pa = float(input())
	print(soln(pa))


t = int(input())
for _ in range(t):
	pa = float(input())
	ma = pa * 10000
	mb = (1 - pa) * 10000
	if pa > 1 - pa:
		sum1 = 2 * (1 - pa) * ma + ma
	else:
		sum1 = 2 * pa * mb + mb
	print(sum1)


T = int(input())
for i in range(T):
	p_a = float(input())
	if p_a > 0.5:
		p_a = 1 - p_a
	print(10000 * (1 - p_a) * (2 * p_a + 1))