Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

Chef has $N$ [6-sided standard dice]. Each die has dimensions $1 \times 1 \times 1$. Since Chef is bored during the quarantine, he decides to stack dice for fun.

First, Chef forms four vertical stacks of dice (not necessarily with the same height; empty stacks are allowed) on his table, which together make up a pile of dice with base area up to $2 \times 2$. Among all such structures, the total visible surface area of Chef's structure must be the smallest possible. 

Then, Chef calculates the number of [pips]  on the visible faces of all dice in the structure. A face of a die is visible if it does not touch the table or another die.

Now, he is wondering: among all possible arrangements of dice, what is the maximum possible total number of visible pips? Since he is busy cooking, he is asking you to solve this.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains a single integer $N$.

------  Output ------
For each test case, print a single line containing one integer ― the maximum possible number of visible pips.

------  Constraints ------
$1 ≤ T ≤ 10^{5}$
$1 ≤ N ≤ 10^{12}$

------  Subtasks ------
Subtask #1 (10 points):
$T ≤ 100$
$N ≤ 4$

Subtask #2 (10 points):
$T ≤ 100$
$N ≤ 8$

Subtask #3 (25 points):
$T ≤ 100$
$N ≤ 10^{4}$

Subtask #4 (55 points): original constraints

----- Sample Input 1 ------ 
1

1
----- Sample Output 1 ------ 
20
----- explanation 1 ------ 
Example case 1: There is only one die. If Chef places it on the table with 1 pip facing down, the visible pips are 2, 3, 4, 5 and 6, and their sum is $20$.

Difficulty: MEDIUM
Tags: Constructive algorithms

Mathematics

Ad-hoc

Starter code:

Solutions:
(L1, L2) = ([0, 20, 36, 51], [16, 21, 22, 22])
for T in range(int(input())):
	n = int(input())
	if n < 4:
		print(L1[n])
	else:
		print(L2[n % 4] + 11 * n)


t = int(input())
for i in range(t):
	n = int(input())
	if n < 4:
		print([0, 20, 36, 51][n])
	else:
		print([16, 21, 22, 22][n % 4] + 11 * n)


tests = int(input())
for i in range(tests):
	dies = int(input())
	ans = 0
	four_stacks = dies // 4
	dies = dies % 4
	if four_stacks > 0:
		ans += four_stacks * 4 * 11
		ans += (4 - dies) * 4
	if dies == 3:
		ans += 51
	elif dies == 2:
		ans += 36
	elif dies == 1:
		ans += 20
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = 0
	if n <= 4:
		y = n % 4
		if y == 1:
			s += 20
		if y == 2:
			s += 36
		if y == 3:
			s += 15 + 18 + 18
		if y == 0:
			s += 15 + 15 + 15 + 15
	else:
		x = n // 4
		s = s + x * 44
		if n % 4 == 1:
			s += 4 + 4 + 4 + 20
		if n % 4 == 2:
			s += 4 + 4 + 36
		if n % 4 == 3:
			s += 4 + 15 + 18 + 18
		if n % 4 == 0:
			s += 4 + 4 + 4 + 4
	print(s)


t = int(input())
while t > 0:
	n = int(input())
	t -= 1
	sum = 0
	if n <= 4:
		y = n % 4
		if y == 1:
			sum += 20
		if y == 2:
			sum += 36
		if y == 3:
			sum += 15 + 18 + 18
		if y == 0:
			sum += 15 + 15 + 15 + 15
	else:
		x = n // 4
		sum = sum + x * 44
		if n % 4 == 1:
			sum += 4 + 4 + 4 + 20
		if n % 4 == 2:
			sum += 4 + 4 + 36
		if n % 4 == 3:
			sum += 4 + 15 + 18 + 18
		if n % 4 == 0:
			sum += 4 + 4 + 4 + 4
	print(sum)


for _ in range(int(input())):
	n = int(input())
	d = {1: 20, 2: 36, 3: 51, 4: 60}
	if n < 5:
		print(d[n])
	elif n % 4 == 0:
		print((n // 4 - 1) * 44 + d[4])
	else:
		print(n // 4 * 44 + d[n % 4] + (4 - n % 4) * 4)


q = int(input())
while q > 0:
	q -= 1
	n1 = int(input())
	total = 0
	n = n1
	if n > 4:
		temp = n // 4
		total += temp * 44
		n -= 4 * temp
		if n == 0:
			total += 16
		elif n % 4 == 3:
			total += 55
		elif n % 4 == 2:
			total += 44
		else:
			total += 32
	elif n == 4:
		total = 60
	elif n == 3:
		total = 51
	elif n == 2:
		total = 36
	else:
		total = 20
	print(total)


q = int(input())
for i in range(q):
	n = int(input())
	dic = {0: 0, 1: 20, 2: 36, 3: 51, 4: 60}
	if n <= 4:
		print(dic[n])
	else:
		a = n % 4
		b = n // 4
		res = b * 44 + dic[a] + 4 * (4 - a)
		print(res)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(20)
	elif n == 2:
		print(36)
	elif n == 3:
		print(51)
	elif n == 4:
		print(60)
	else:
		rem = n % 4
		ans = (n - rem) * 11
		if rem == 0:
			ans += 16
		elif rem == 1:
			ans += 32
		elif rem == 2:
			ans += 44
		elif rem == 3:
			ans += 55
		print(ans)


x = int(input())
for i in range(x):
	n = int(input())
	k = (n - 1) // 4
	if n % 4 == 3:
		if n == 3:
			s = 51
		else:
			s = 51 + 44 * k + 4
	elif n % 4 == 1:
		if n == 1:
			s = 20
		else:
			s = 20 + 44 * k + 12
	elif n % 4 == 2:
		if n == 2:
			s = 36
		else:
			s = 36 + 44 * k + 8
	else:
		s = 60 + 44 * k
	print(s)


for j in range(int(input())):
	n = int(input())
	ans = [20, 36, 51]
	if n < 4:
		print(ans[n - 1])
	else:
		ans = [0] + ans
		(en_l, tp_l) = (n // 4, n % 4)
		print((en_l - 1) * 44 + 60 + ans[tp_l] - 4 * tp_l)


for _ in range(int(input())):
	N = int(input())
	height = N // 4
	base = 44 * height
	if height == 0:
		if N % 4 == 0:
			print(base + 16)
		if N % 4 == 1:
			print(base + 20)
		if N % 4 == 2:
			print(base + 36)
		if N % 4 == 3:
			print(base + 51)
	else:
		if N % 4 == 0:
			print(base + 16)
		if N % 4 == 1:
			print(base + 32)
		if N % 4 == 2:
			print(base + 44)
		if N % 4 == 3:
			print(base + 55)


for test_case in range(int(input())):
	n = int(input())
	if n <= 4:
		print(20 if n == 1 else 36 if n == 2 else 51 if n == 3 else 60 if n == 4 else 0)
	elif n % 4 == 0:
		print(60 + 44 * (int(n / 4) - 1))
	else:
		count = 24 + 44 * (int(n / 4) - 1)
		if n % 4 == 1:
			count = count + 16 + 36
			print(count)
		elif n % 4 == 2:
			count = count + 28 + 36
			print(count)
		elif n % 4 == 3:
			count = count + 39 + 36
			print(count)


for test_case in range(int(input())):
	n = int(input())
	count = 44 * max(0, int(n / 4) - 1)
	count = count + (36 if n >= 4 else 0)
	count = count + (20 if n % 4 == 1 else 0) + (36 if n % 4 == 2 else 0) + (51 if n % 4 == 3 else 0) + (24 if n % 4 == 0 else 0)
	if n > 4:
		count = count + 6 * (4 - n % 4 if n % 4 != 0 else 0) + 2 * (n % 4)
	print(count)


for i in range(int(input())):
	die = int(input())
	arr = [0, 20, 36, 51]
	if die < 4:
		print(arr[die])
	elif die % 4 == 1:
		print(2 * 1 + 3 * 1 + 4 * 4 + 5 * die + 6 * die)
	elif die % 4 == 0:
		print(4 * 4 + 5 * die + 6 * die)
	else:
		j = 3 * 2 + 4 * 4 + 5 * die + 6 * die
		print(j)


for _ in range(int(input())):
	k = int(input())
	a = [20, 36, 51, 60]
	if k < 5:
		print(a[k - 1])
		continue
	steps = int(k / 4)
	answer = 44 * steps
	if k % 4 == 1:
		answer = answer + 32
	elif k % 4 == 2:
		answer = answer + 44
	elif k % 4 == 3:
		answer = answer + 55
	else:
		answer = answer + 16
	print(answer)


val = [0, 20, 36, 51]
t = int(input())
for i in range(t):
	n = int(input())
	b = n // 4
	t = n % 4
	total = (b - 1) * 44 + 60
	if b == 0:
		print(val[n])
	else:
		print(val[t] + total - 4 * t)


N = int(input())
res = 0
for i in range(N):
	no_of_dice = int(input())
	d = {0: 0, 1: 20, 2: 36, 3: 51}
	dice_on_top = no_of_dice % 4
	height_of_stack = no_of_dice // 4
	full_levels = (height_of_stack - 1) * 44 + 60
	if height_of_stack == 0:
		print(d.get(no_of_dice))
	else:
		res = full_levels + d.get(dice_on_top) - 4 * dice_on_top
		print(res)


import sys
T = int(sys.stdin.readline())
ans = [0, 20, 36, 51, 16, 12, 8, 4]
for i in range(T):
	N = int(sys.stdin.readline())
	topDice = N % 4
	H = 44 * (N // 4)
	if not H:
		sys.stdout.write(str(ans[topDice]) + '\n')
		continue
	sys.stdout.write(str(ans[topDice] + H + ans[topDice + 4]) + '\n')


tries = int(input())
for i in range(0, tries):
	dices = int(input())
	mydict = {1: 20, 2: 36, 3: 51, 4: 60, 5: 76, 6: 88, 7: 99, 8: 104}
	if dices // 8 == 0:
		print(mydict.get(dices))
	else:
		print(44 * (dices // 4 - 1) + mydict.get(dices % 4 + 4))


import sys
T = int(sys.stdin.readline())
ans = [0, 20, 36, 51]
for i in range(T):
	N = int(sys.stdin.readline())
	topDice = N % 4
	H = 44 * (N // 4)
	sys.stdout.write(str(ans[topDice] + H + min(H, 1) * 4 * (4 - topDice)) + '\n')


def Solution(arr):
	sol_arr = []
	for dice_num in arr:
		if dice_num == 1:
			sol_arr.append(20)
		if dice_num == 2:
			sol_arr.append(36)
		if dice_num == 3:
			sol_arr.append(51)
		if dice_num == 4:
			sol_arr.append(60)
		if dice_num > 4:
			height = dice_num // 4
			remain_ontop = dice_num % 4
			if remain_ontop == 1:
				sol_arr.append(height * 44 + 20 + 4 * (4 - remain_ontop))
			if remain_ontop == 2:
				sol_arr.append(44 * height + 36 + 4 * (4 - remain_ontop))
			if remain_ontop == 3:
				sol_arr.append(44 * height + 51 + 4 * (4 - remain_ontop))
			if remain_ontop == 0:
				sol_arr.append(44 * height + 4 * (4 - remain_ontop))
	return sol_arr
arr = []
for i in range(int(input())):
	arr.append(int(input()))
for i in Solution(arr):
	print(i)


T = int(input())
t = 0
while t < T:
	a = str(input())
	a = int(a)
	answer = {1: 20, 2: 36, 3: 51, 4: 60, 5: 76, 6: 88, 7: 99, 8: 104}
	if a in answer:
		print(answer[a])
		t += 1
		continue
	final_ans = 44 * (a // 4 - 1) + answer[4 + a % 4]
	print(final_ans)
	t += 1


t = int(input())
while t != 0:
	a = int(input())
	l = [0, 20, 36, 51]
	ans = 0
	dice_on_top = a % 4
	height = a // 4
	enclosed = (height - 1) * 44 + 60
	if height == 0:
		ans = l[a]
	else:
		ans = enclosed + l[dice_on_top] - 4 * dice_on_top
	print(int(ans))
	t -= 1


t = int(input())
while t:
	n = int(input())
	sm = n // 4 * 44
	rem = n % 4
	if n >= 4:
		if rem == 0:
			sm += 16
		if rem == 1:
			sm += 32
		if rem == 2:
			sm += 44
		if rem == 3:
			sm += 55
		print(sm)
	else:
		if n == 1:
			print(20)
		if n == 2:
			print(36)
		if n == 3:
			print(51)
	t -= 1


import sys

def get_int():
	return int(sys.stdin.readline().strip())
for i in range(get_int()):
	N = int(input())
	ans = 0
	if N == 1:
		ans = 20
	elif N == 2:
		ans = 36
	elif N == 3:
		ans = 51
	elif N == 4:
		ans = 60
	else:
		levels = N // 4
		ans = levels * 44
		rem = N % 4
		if rem == 0:
			ans += 16
		elif rem == 1:
			ans += 32
		elif rem == 2:
			ans += 44
		elif rem == 3:
			ans += 55
	print(ans)


t = int(input())
l = [[1, 20], [2, 36], [3, 51], [4, 60], [8, 104]]
while t:
	n = int(input())
	if n <= 4:
		for i in range(0, 5):
			if l[i][0] == n:
				print(l[i][1])
				break
	else:
		d = n % 4
		n1 = (n - d) // 4
		r = (n1 - 1) * 44 + 60
		if d == 1:
			r += 20 - 4
		elif d == 2:
			r += 36 - 8
		elif d == 3:
			r += 51 - 12
		print(r)
	t -= 1


T = int(input())
for i in range(T):
	N = int(input())
	ans = 0
	if N == 1:
		ans = 20
	elif N == 2:
		ans = 36
	elif N == 3:
		ans = 51
	elif N == 4:
		ans = 60
	else:
		levels = N // 4
		ans = levels * 44
		rem = N % 4
		if rem == 0:
			ans += 16
		elif rem == 1:
			ans += 32
		elif rem == 2:
			ans += 44
		elif rem == 3:
			ans += 55
	print(ans)


import sys

def get_inpt():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def p_str(x):
	sys.stdout.write(x + '\n')

def p_int(x):
	sys.stdout.write(str(x) + '\n')

def p_arr(arr):
	sys.stdout.write(' '.join(map(str, arr)) + '\n')
for _ in range(get_int()):
	n = get_int()
	s = n // 4
	k = n % 4
	sum_ = 11 * (n - k)
	if n == 1:
		sum_ = 20
	elif n == 2:
		sum_ = 36
	elif n == 3:
		sum_ = 51
	elif n == 4:
		sum_ = 60
	elif k == 1:
		sum_ += 32
	elif k == 2:
		sum_ += 44
	elif k == 3:
		sum_ += 55
	elif k == 0:
		sum_ += 16
	print(sum_)


t = int(input())
for i in range(t):
	n = int(input())
	answer = 0
	if n == 1:
		answer = 20
	elif n == 2:
		answer = 36
	elif n == 3:
		answer = 51
	elif n == 4:
		answer = 60
	else:
		levels = n // 4
		answer = levels * 44
		remainder = n % 4
		if remainder == 0:
			answer += 16
		elif remainder == 1:
			answer += 32
		elif remainder == 2:
			answer += 44
		elif remainder == 3:
			answer += 55
	print(answer)


def solve(n):
	topPts = [20, 36, 51, 60]
	bottomLayers = int((n - 1) / 4)
	t = n % 4
	s = (bottomLayers >= 1) * bottomLayers * 44 + (n > 4 and t > 0) * (4 - t) * 4 + topPts[t - 1]
	return s
t = int(input())
for i in range(1, t + 1):
	k = int(input())
	j = solve(k)
	print(str(j))


F = [0, 6, 11, 15, 18, 20, 21]

def f(n):
	return F[n]

def h(n):
	return {1: f(5), 2: 2 * f(4), 3: 2 * f(4) + f(3), 4: 4 * f(3)}[n]

def g(n):
	k = n % 4 or 4
	return h(k) + (n > 4) * ((4 - k) * f(3) + k * f(2)) + max(n - k - 4, 0) * f(2)
t = int(input())
for _ in range(t):
	n = int(input())
	print(g(n))


def f(n):
	return sum(range(6, 6 - n, -1))

def h(n):
	return (n == 1) * f(5) + (n == 2) * (2 * f(4)) + (n == 3) * (2 * f(4) + f(3)) + (n == 4) * (4 * f(3))

def g(n):
	k = n % 4 + (n % 4 == 0) * 4
	return h(k) + (n > 4) * ((4 - k) * f(3) + k * f(2)) + max(n - k - 4, 0) * f(2)
t = int(input())
for _ in range(t):
	n = int(input())
	print(g(n))


for _ in range(int(input())):
	n = int(input())
	c = 0
	c += 11 * (n - n % 4)
	if n >= 4:
		c += 4 * (4 - n % 4)
	t = n % 4
	if t == 1:
		c += 20
	elif t == 2:
		c += 36
	elif t == 3:
		c += 51
	print(c)


for t in range(int(input())):
	n = int(input())
	if n // 4 < 1:
		if n % 4 == 1:
			print(20)
		elif n % 4 == 2:
			print(36)
		elif n % 4 == 3:
			print(51)
	else:
		c = 0
		floor = n // 4
		c += 44 * (n // 4)
		if n % 4 == 1:
			c += 20 + 3 * 4
		elif n % 4 == 2:
			c += 36 + 2 * 4
		elif n % 4 == 3:
			c += 51 + 4
		else:
			c += 16
		print(c)


f = [20, 36, 51, 60]
for i in range(int(input())):
	n = int(input())
	if n <= 4:
		print(f[n - 1])
	elif n % 4 == 0:
		print(44 * (n // 4 - 1) + 60)
	else:
		p = n // 4
		r = p * 44
		rem = n % 4
		dd = rem
		pp = 4 - dd
		pp = pp * 4
		r = r + pp
		if dd == 0:
			dd = 4
		print(f[dd - 1] + r)


t = int(input())
for i in range(t):
	n = int(input())
	if n <= 4:
		s = 0
		if n == 1:
			print(20)
		elif n == 2:
			print(36)
		elif n == 3:
			print(51)
		elif n == 4:
			print(60)
	else:
		k = n % 4
		q = n // 4
		if k == 1:
			s = q * 44 + 12 + 20
		elif k == 2:
			s = q * 44 + 8 + 36
		elif k == 3:
			s = q * 44 + 4 + 51
		elif k == 0:
			s = q * 44 + 16
		print(s)


for _ in range(int(input())):
	n = int(input())
	if n <= 4:
		top = [20, 36, 51, 60]
		print(top[n - 1])
	ans = 0
	if n > 4:
		height = n // 4
		ans += height * 44
		if n % 4 == 1:
			ans += 20 + 12
		elif n % 4 == 2:
			ans += 36 + 8
		elif n % 4 == 3:
			ans += 51 + 4
		elif n % 4 == 0:
			ans += 16
		print(ans)


for _ in range(int(input())):
	n = int(input())
	height = n // 4
	left = n % 4
	one_comp_level_pip = 44
	if left == 1:
		pip_left = 20
	elif left == 2:
		pip_left = 36
	elif left == 3:
		pip_left = 51
	elif left == 0:
		pip_left = 0
	if height > 0:
		top_visible_pip = (4 - left) * 4
	else:
		top_visible_pip = 0
	print(one_comp_level_pip * height + pip_left + top_visible_pip)


t = int(input())
for _ in range(t):
	n = int(input())
	dice = [0, 20, 36, 51, 60]
	pips = 0
	if n > 4:
		k = n % 4
		l = n // 4
		pips += (l - 1) * 44 + (dice[k] + 11 * k) + (4 - k) * 15
	else:
		pips = dice[n]
	print(pips)


for _ in range(int(input())):
	n = int(input())
	if n == 1:
		print(20)
	elif n == 2:
		print(36)
	elif n == 3:
		print(51)
	elif n == 4:
		print(60)
	else:
		layers = n // 4
		rem = n % 4
		if rem == 0:
			r = 0
		elif rem == 1:
			r = 20
		elif rem == 2:
			r = 36
		elif rem == 3:
			r = 51
		ans = 44 * layers + (4 - rem) * 4 + r
		print(ans)


def solve(n):
	if n == 1:
		return 20
	elif n == 2:
		return 36
	elif n == 3:
		return 51
	elif n == 4:
		return 60
	rem = n % 4
	empty = 4 - rem
	floors = n // 4
	ans = floors * 44 + empty * 4
	if rem == 1:
		ans += 20
	elif rem == 2:
		ans += 36
	elif rem == 3:
		ans += 51
	return ans
local_ans = []
local_mode = False

def getArr():
	return list(map(int, input().split()))

def getNums():
	return map(int, input().split())
t = int(input())
for _ in range(t):
	n = int(input())
	if local_mode:
		local_ans.append(solve(n))
	else:
		print(solve(n))
if local_mode:

	def printAll(sol):
		for val in sol:
			print(val)
	printAll(local_ans)


for _ in range(int(input())):
	n = int(input())
	extra = n % 4
	enclosed = n // 4
	tempArr = [0, 20, 36, 51]
	if enclosed == 0:
		ans = tempArr[extra]
	else:
		ans = (enclosed - 1) * 44 + 60 + (tempArr[extra] - 4 * extra)
	print(ans)


import numpy as vcy

def solve(n):
	poss = vcy.array([20, 36, 51, 60])
	first = 20
	sec = 18
	third = 15
	four = 11
	if n == 1:
		print(first, '\n')
	elif n == 2:
		print(sec * 2, '\n')
	elif n == 3:
		print(sec * 2 + third, '\n')
	elif n == 4:
		print(third * 4, '\n')
	else:
		n1 = int(n / 4)
		n2 = 60 + 44 * (n1 - 1)
		if n % 4 == 0:
			print(n2, '\n')
		else:
			print(n2 + poss[n % 4 - 1] - 4 * (n % 4))
for _ in range(int(input())):
	n = int(input())
	solve(n)


t = int(input())
for i in range(t):
	n = int(input())
	if n >= 4:
		if n % 4 == 0:
			ans = (n // 4 - 1) * 44
			ans += 60
			print(ans)
		elif n % 4 == 1:
			ans = (n // 4 - 1) * 44
			ans += 76
			print(ans)
		elif n % 4 == 2:
			ans = (n // 4 - 1) * 44
			ans += 88
			print(ans)
		elif n % 4 == 3:
			ans = (n // 4 - 1) * 44
			ans += 99
			print(ans)
	elif n == 1:
		print(20)
	elif n == 2:
		print(36)
	elif n == 3:
		print(51)


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = [20, 36, 51, 60]
		if n >= 1 and n < 5:
			print(arr[n - 1])
		else:
			top = n % 4
			enclosed = n // 4
			if top != 0:
				sum1 = (enclosed - 1) * 44 + 60 + arr[top - 1] - 4 * top
			else:
				sum1 = (enclosed - 1) * 44 + 60
			print(sum1)
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	a = n // 4
	b = n % 4
	sum = 0
	if a >= 1:
		sum += (a - 1) * 44
		sum += 60
	if b == 1:
		sum += 16
	elif b == 2:
		sum += 28
	elif b == 3:
		sum += 39
	if a == 0:
		sum += b * 4
	print(sum)


d = {1: 20, 2: 36, 3: 51, 4: 60}
for _ in range(int(input())):
	n = int(input())
	if n <= 4:
		print(d[n])
	else:
		var1 = n // 4
		var2 = n % 4
		res = 44 * var1
		if var2 != 0:
			res += d[var2] + 4 * (4 - var2)
		else:
			res += 16
		print(res)


li = [0, 20, 36, 51, 60]
re = {1: 16, 2: 12, 3: 11, 0: 5}

def solve(N):
	base_sum = li[4]
	if N <= 4:
		return li[N]
	sum = base_sum
	r = N % 4
	while r > 0:
		sum += re[r]
		r -= 1
	sum += (N // 4 - 1) * 44
	return sum
T = int(input())
while T > 0:
	n = int(input())
	print(solve(n))
	T -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	ans = 0
	remain = n // 4
	ans += 44 * remain
	n = n % 4
	if n == 0:
		if remain > 0:
			ans += 16
	elif n == 1:
		if remain > 0:
			ans += 12
		ans += 20
	elif n == 2:
		if remain > 0:
			ans += 8
		ans += 36
	else:
		if remain > 0:
			ans += 4
		ans += 51
	print(ans)


def main():
	t = int(input())
	for i in range(t):
		k = int(input())
		ans = 0
		t = k % 4
		if t == 0:
			ans = 0
		if t == 1:
			ans = 20
		if t == 2:
			ans = 36
		if t == 3:
			ans = 51
		n = int(k / 4)
		z = n * 11
		if k >= 4:
			ans = ans + n * 11 * 4 + (4 - t) * 4
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	r = n % 4
	div = n // 4
	res = div * 44
	if r == 0:
		res += 4 * 4
	elif r == 1:
		res += 20
		if div > 0:
			res += 4 * 3
	elif r == 2:
		res += 36
		if div > 0:
			res += 4 * 2
	else:
		res += 51
		if div > 0:
			res += 4 * 1
	print(res)


for i in range(int(input())):
	n = int(input())
	d = {1: 20, 2: 36, 3: 51, 4: 60}
	d1 = {1: 16, 2: 28, 3: 39, 4: 44}
	r = n % 4
	q = n // 4
	if n <= 4:
		print(d[n])
	elif n % 4 == 0:
		print(d[4] + (q - 1) * 44)
	else:
		print(d[4] + (q - 1) * 44 + d1[r])


d = {1: 20, 2: 36, 3: 51, 4: 60}
for _ in range(int(input())):
	n = int(input())
	if n <= 4:
		print(d[n])
	else:
		level = n // 4
		remaining = n % 4
		if remaining == 0:
			print(level * d[4] - (n - 4) * 4)
		else:
			print(level * d[4] + d[remaining] - (n - 4) * 4)


for _ in range(int(input())):
	n = int(input())
	if n < 4:
		if n == 3:
			print(51)
		elif n == 2:
			print(36)
		elif n == 1:
			print(20)
	elif n % 4 == 0:
		print(15 * 4 + max(0, (n - 4) * 11))
	elif n % 4 == 3:
		print(2 * 18 + 2 * 15 + max(0, (n - 4) * 11))
	elif n % 4 == 2:
		print(2 * 18 + 2 * 15 + max(0, (n - 4) * 11))
	elif n % 4 == 1:
		print(20 + 3 * 15 + max(0, (n - 4) * 11))


t = int(input())
l = [0, 20, 36, 51]
for x in range(t):
	n = int(input())
	r = int(n % 4)
	c = int(n / 4)
	m = (c - 1) * 44 + 60
	p = 4 - r
	if c > 0:
		print(m + l[r] - r * 4)
	else:
		print(l[r])


t = int(input())
for i in range(t):
	n = int(input())
	top = n % 4
	h = n // 4
	th = (h - 1) * 44 + 60
	list1 = [0, 20, 36, 51]
	if h == 0:
		total = list1[n]
	else:
		total = th + list1[top] - 4 * top
	print(total)


testcases = int(input())
nList = []
for i in range(testcases):
	nList.append(int(input()))
for n in nList:
	q = n // 4
	r = n % 4
	lastLine = 0 if r == 0 else 20 if r == 1 else 36 if r == 2 else 51
	maxim = lastLine if n < 4 else max(q - 1, 0) * 44 + (4 - r) * 15 + r * 11 + lastLine
	print(maxim)


T = int(input())
for _ in range(T):
	N = int(input())
	if N == 1:
		print(20)
	elif N == 2:
		print(36)
	elif N == 3:
		print(51)
	elif N == 4:
		print(60)
	elif N > 4:
		d = N % 4
		q = N // 4
		if d == 1:
			x = 60 * q + 20 - 4 * (N - 4)
			print(x)
		elif d == 2:
			x = 60 * q + 36 - 4 * (N - 4)
			print(x)
		elif d == 3:
			x = 60 * q + 51 - 4 * (N - 4)
			print(x)
		elif d == 0:
			x = 60 * q + 0 - 4 * (N - 4)
			print(x)
		else:
			pass


t = int(input())
for i in range(t):
	n = int(input())
	d1 = [0, 20, 36, 51, 60]
	if n > 4:
		on_top = n % 4
		below = n // 4
		s = below * 44 + d1[on_top] + (4 - on_top) * 4
	else:
		s = d1[n]
	print(int(s))


def getNumOfPips(n):
	getValue = lambda x, y: (4 - y) * 4 if x > 0 else 0
	retVal = 0
	numOfStacks = n // 4
	retVal = numOfStacks * 44
	remainingDice = n % 4
	if remainingDice == 1:
		retVal = retVal + getValue(numOfStacks, remainingDice) + 20
	elif remainingDice == 2:
		retVal = retVal + getValue(numOfStacks, remainingDice) + 36
	elif remainingDice == 3:
		retVal = retVal + getValue(numOfStacks, remainingDice) + 51
	elif remainingDice == 0:
		retVal = retVal + 16
	return retVal
for testCase in range(int(input())):
	numOfPips = 0
	n = int(input())
	numOfPips = getNumOfPips(n)
	print(numOfPips)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	if n % 4 == 1:
		ans += 20
	elif n % 4 == 2:
		ans += 36
	elif n % 4 == 3:
		ans += 51
	x = n // 4
	ans += x * 44
	if x >= 1:
		ans += 4 * (4 - n % 4)
	print(ans)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	ans = ''
	tmp = [0, 20, 36, 51]
	for _ in range(ii()):
		n = ii()
		x = n // 4 * 44 + tmp[n % 4]
		if n // 4 > 0:
			x += (4 - n % 4) * 4
		ans += str(x) + '\n'
	print(ans)
main()


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	p = n // 4
	q = n % 4
	if q == 1:
		r = 20
	elif q == 2:
		r = 36
	elif q == 3:
		r = 51
	else:
		r = 0
	if p < 1:
		ans = r
	else:
		ans = p * 44 + r + 4 * (4 - q)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	n1 = 6 + 5 + 4 + 3 + 2
	n2 = 2 * 6 + 2 * 5 + 2 * 4 + 2 * 3
	n3 = 3 * 6 + 3 * 5 + 3 * 4 + 2 * 3
	if n == 1:
		print(n1)
		continue
	if n == 2:
		print(n2)
		continue
	if n == 3:
		print(n3)
		continue
	x = int(n / 4)
	p = 6 * 4 + 5 * 4
	ans = x * p + 4 * 4
	if n % 4 > 0:
		if n % 4 == 1:
			ans = ans + n1 - 4
		elif n % 4 == 2:
			ans = ans + n2 - 2 * 4
		else:
			ans = ans + n3 - 3 * 4
	print(ans)


t = int(input())
l = []
for i in range(t):
	n = int(input())
	d = n % 4
	n = n // 4
	s = n * 44
	if d == 0:
		s = s + 16
	elif d == 1:
		s = s + 20
		if n > 0:
			s = s + 12
	elif d == 2:
		s = s + 36
		if n > 0:
			s = s + 8
	else:
		s = s + 51
		if n > 0:
			s = s + 4
	l.append(s)
for i in l:
	print(i)