Translator's note: in Russia's most widespread grading system, there are four grades: 5, 4, 3, 2, the higher the better, roughly corresponding to A, B, C and F respectively in American grading system.

The term is coming to an end and students start thinking about their grades. Today, a professor told his students that the grades for his course would be given out automatically  — he would calculate the simple average (arithmetic mean) of all grades given out for lab works this term and round to the nearest integer. The rounding would be done in favour of the student — $4.5$ would be rounded up to $5$ (as in example 3), but $4.4$ would be rounded down to $4$.

This does not bode well for Vasya who didn't think those lab works would influence anything, so he may receive a grade worse than $5$ (maybe even the dreaded $2$). However, the professor allowed him to redo some of his works of Vasya's choosing to increase his average grade. Vasya wants to redo as as few lab works as possible in order to get $5$ for the course. Of course, Vasya will get $5$ for the lab works he chooses to redo.

Help Vasya — calculate the minimum amount of lab works Vasya has to redo.


-----Input-----

The first line contains a single integer $n$ — the number of Vasya's grades ($1 \leq n \leq 100$).

The second line contains $n$ integers from $2$ to $5$ — Vasya's grades for his lab works.


-----Output-----

Output a single integer — the minimum amount of lab works that Vasya has to redo. It can be shown that Vasya can always redo enough lab works to get a $5$.


-----Examples-----
Input
3
4 4 4

Output
2

Input
4
5 4 5 5

Output
0

Input
4
5 3 3 5

Output
1



-----Note-----

In the first sample, it is enough to redo two lab works to make two $4$s into $5$s.

In the second sample, Vasya's average is already $4.75$ so he doesn't have to redo anything to get a $5$.

In the second sample Vasya has to redo one lab work to get rid of one of the $3$s, that will make the average exactly $4.5$ so the final grade would be $5$.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Greedy algorithms


Solutions:
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
s = sum(a)
line = 4.5 * n
l = line - s
x = 0
while l > 0:
	l -= 5 - a[x]
	x += 1
print(x)


noLabWorks = int(input())
listGrades = list(map(int, input().split(' ')))
listGrades.sort()
desiredTotal = 4.5 * noLabWorks
currentTotal = sum(listGrades)
index = 0
while currentTotal < desiredTotal:
	increment = 5 - listGrades[index]
	currentTotal += increment
	index += 1
print(index)


n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
while sum(a) < 4.5 * n:
	a[i] = 5
	i += 1
print(i)


n = int(input())
arr = list(map(int, input().split()))
scoreSum = 0
average = 0
subject = 0
arr.sort()
for i in range(n):
	scoreSum += arr[i]
average = scoreSum / n
i = 0
if average >= 4.5:
	print(subject)
else:
	while average < 4.5:
		scoreSum += 5 - arr[i]
		average = scoreSum / n
		subject += 1
		i += 1
	print(subject)


def solve(N, A):
	thre = N * 4 + N // 2
	if N % 2 > 0:
		thre += 1
	A.sort()
	s = sum(A)
	c = 0
	while s < thre:
		s += 5 - A[c]
		c += 1
	return c

def main():
	N = int(input())
	A = [int(e) for e in input().split(' ')]
	assert len(A) == N
	print(solve(N, A))
main()


n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
av = s / n
c = 0
a.sort()
while av < 4.5 and a:
	for i in range(n):
		if a[i] < 5:
			a[i] = 5
			c += 1
		av = sum(a) / n
		if av >= 4.5:
			break
print(c)


n = int(input())
a = list(map(int, input().split()))
a.sort()
summ = sum(a)
if summ / n >= 4.5:
	print(0)
else:
	for (i, num) in enumerate(a):
		if (summ + 5 - num) / n >= 4.5:
			print(i + 1)
			break
		else:
			summ += 5 - num


n = int(input())
ar = list(map(int, input().split()))
ar = sorted(ar)
idx = 0
while sum(ar) / len(ar) < 4.5 and idx < len(ar):
	ar[idx] = 5
	idx += 1
print(idx)


n = int(input())
s = sorted(list(map(int, input().split())))
l = s
c = 0
for i in range(n):
	a = sum(s) / n
	if a >= 4.5:
		break
	if s[i] < 5:
		s[i] = 5
		a = sum(s) / n
		c += 1
print(c)


import statistics as st

def meann(a):
	x = st.mean(a)
	return x
n = int(input())
a = [int(i) for i in input().split()]
ans = 0
a.sort()
if meann(a) >= 4.5:
	ans = 0
else:
	for i in range(n):
		if a[i] < 5:
			ans += 1
			a[i] = 5
			if meann(a) >= 4.5:
				break
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
l = sorted(l)
x = len(l)
s = sum(l) / x
c = i = 0
for i in range(x):
	if s < 4.5:
		if i < x:
			l[i] = 5
			i += 1
			c += 1
			s = sum(l) / x
print(c)


n = int(input())
a = list(map(int, input().split()))
l = len(a)
ans = 0
if sum(a) / l >= 4.5:
	print(0)
else:
	a.sort()
	for i in range(len(a)):
		a[i] = 5
		ans += 1
		if sum(a) / l >= 4.5:
			break
	print(ans)


n = int(input())
mylist = [int(x) for x in input().split()]
sum = 0
for x in mylist:
	sum += x
arav = sum / n
if int(arav * 10 % 10) > 4:
	arav = int(arav) + 1
else:
	arav = int(arav)
if arav == 5:
	print(0)
else:
	ans = 0
	mylist.sort()
	for x in mylist:
		sum -= x
		sum += 5
		arav = sum / n
		if int(arav * 10 % 10) > 4:
			arav = int(arav) + 1
		else:
			arav = int(arav)
		ans += 1
		if arav == 5:
			print(ans)
			break


import math
n = int(input())
l = list(map(int, input().strip().split()))
req = math.ceil(n * 4.5)
l.sort()
f = sum(l)
count = 0
i = 0
while f < req and i < n:
	f = f + 5 - l[i]
	i = i + 1
	count = count + 1
print(count)


n = int(input())
l = list(map(int, input().split()))
if sum(l) / n >= 4.5:
	print('0')
else:
	val = n * 4.5
	x = val - sum(l)
	l.sort()
	count = 0
	for i in range(n):
		diff = 5 - l[i]
		if diff >= x and x > 0:
			count += 1
			x -= diff
		elif x > 0:
			count += 1
			x -= diff
	print(count)


n = int(input()) * 4.5
global s_obt
s_obt = 0

def myord(num):
	global s_obt
	s_obt += num
	return num
entrada = (int(x) for x in input().split())
entrada = sorted(entrada, key=myord)
res = 0
while s_obt < n:
	s_obt += 5 - entrada[res]
	res += 1
print(res)


n = int(input())
g = [int(i) for i in input().split(' ')]
g = sorted(g)
gr = sum(g) / len(g)
i = 0
while gr < 4.5:
	g[i] = 5
	gr = sum(g) / len(g)
	i += 1
print(i)


n = int(input())
m = sorted(list(map(int, input().split())))
count = 0
i = 0
if sum(m) / n >= 4.5:
	print(0)
else:
	while sum(m) / n < 4.5:
		m[i] = 5
		count += 1
		i += 1
	print(count)


n = int(input())
A = [0]
B = list(map(int, input().split()))
sum = 0
for i in B:
	sum += i
	A.append(i)
A.sort()
ans = -1
cnt = 0
for i in range(n + 1):
	sum -= A[i]
	if i >= 1:
		sum += 5
	a = sum / n
	b = a - int(a)
	if b >= 0.5:
		a = int(a) + 1
	else:
		a = int(a)
	if a >= 5:
		ans = i
		break
print(ans - cnt)


import sys

def main():
	n = int(sys.stdin.readline())
	A = list(map(int, sys.stdin.readline().split()))
	su = sum(A)
	if su / n >= 4.5:
		print(0)
		return
	else:
		A = sorted(A)
		f = 0
		for k in range(n):
			q = A[k]
			su -= q
			su += 5
			f += 1
			if su / n >= 4.5:
				break
		print(f)
	return
main()


n = int(input())
mas = list(map(int, input().split()))
mas.sort()
k = sum(mas)
for i in range(n + 1):
	if k / n >= 4.5:
		print(i)
		break
	else:
		k -= mas[i]
		k += 5


n = int(input())
a = list(map(int, input().split()))
a.sort()
b = sum(a)
cou = 0
for i in a:
	if b / n >= 4.5:
		break
	else:
		b = b - i + 5
		cou += 1
print(cou)


n = int(input())
m = [int(x) for x in input().split()]
m.sort()
avg = sum(m) / n
cnt = 0
while avg < 4.5:
	m[0] = 5
	cnt += 1
	m.sort()
	avg = sum(m) / n
print(cnt)


n = int(input())
grades = sorted(list(map(int, input().split())))
summed = sum(grades)
redo = 0
if summed / len(grades) < 4.5:
	i = 0
	while summed / len(grades) < 4.5:
		diff = 5 - grades[i]
		summed += diff
		redo += 1
		i += 1
print(redo)


n = int(input().rstrip().split()[0])
data = [int(x) * 10 for x in input().rstrip().split()]
data.sort()
total = sum(data)
target = 45 * n
if total >= target:
	print(0)
else:
	i = 0
	while total < target:
		total += 50 - data[i]
		i += 1
	print(i)


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def multi():
	return map(int, input().split())

def strmulti():
	return map(str, inp().split())

def lis():
	return list(map(int, inp().split()))

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def stringlis():
	return list(map(str, inp().split()))

def out(var):
	sys.stdout.write(str(var))

def printlist(a):
	print(' '.join((str(a[i]) for i in range(len(a)))))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def sum(n):
	sum = 0
	for i in n:
		sum += int(i)
	return sum
n = int(input())
a = lis()
sum = 0
for i in a:
	sum += i
a.sort()
if sum / n >= 4.5:
	print(0)
else:
	for i in range(n):
		if (5 - a[i] + sum) / n >= 4.5:
			print(i + 1)
			exit(0)
		sum += 5 - a[i]


(n, l, a) = (int(input()), sorted(map(int, input().split())), 0)
while sum(l) / n < 4.5:
	l[a] = 5
	a += 1
print(a)


n = int(input())
a = list(map(int, input().split(' ')))
s = sum(a)
if s >= n * 4.5:
	print(0)
else:
	x = n * 4.5 - s
	i = 0
	a.sort()
	while x > 0:
		x -= 5 - a[i]
		i += 1
	print(i)


n = int(input())
a = sorted(map(int, input().split()))
min_score = 5 * n
while (min_score - 1.0) / n >= 4.5:
	min_score -= 1
ans = 0
total = sum(a)
while total < min_score:
	total += 5 - a[ans]
	ans += 1
print(ans)


n = int(input())
s = [int(i) for i in input().split()]
ans = 0
while sum(s) / n < 4.5:
	s.remove(min(s))
	s.append(5)
	ans += 1
print(ans)


import collections
from functools import cmp_to_key
import math
import sys

def getIntList():
	return list(map(int, input().split()))
import bisect
try:
	import numpy
	dprint = print
	dprint('debug mode')
except ModuleNotFoundError:

	def dprint(*args, **kwargs):
		pass

def makePair(z):
	return [(z[i], z[i + 1]) for i in range(0, len(z), 2)]
(n,) = getIntList()
zs = getIntList()
zs.sort()
nows = sum(zs)
if nows * 2 >= 9 * n:
	print(0)
	sys.exit()
for i in range(n):
	t = 5 - zs[i]
	nows += t
	dprint(nows)
	if nows * 2 >= 9 * n:
		print(i + 1)
		sys.exit()


import math
n = int(input())
a = list(map(int, input().split()))
a.sort()
p = sum(a) / len(a)
if p >= 4.5:
	print('0')
else:
	cnt = 0
	while p < 4.5:
		a[0] = 5
		cnt += 1
		a.sort()
		p = sum(a) / len(a)
	print(cnt)


n = int(input())
A = [int(i) for i in input().split()]
A.sort()
needed = 4.5 * n
have = sum(A)
if have >= needed:
	print(0)
else:
	for i in range(n):
		have = have - A[i] + 5
		if have >= needed:
			print(i + 1)
			break


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = 0
s = sum(a)
for i in range(n):
	if s / n * 10 >= 45:
		break
	s += 5 - a[i]
	ans += 1
print(ans)


n = int(input())
li = list(map(int, input().split()))
count = 0
while sum(li) / n < 4.5:
	li[li.index(min(li))] = 5
	count += 1
print(count)


import math
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
ans = 0
summ = sum(a)
if summ * 10 < n * 45:
	for i in range(n):
		summ += 5 - a[i]
		ans += 1
		if summ * 10 >= n * 45:
			break
	print(ans)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
if sum(a) / len(a) >= 4.5:
	print(0)
else:
	a.sort()
	s = sum(a)
	ln = len(a)
	for i in range(ln):
		s += 5 - a[i]
		if s / ln >= 4.5:
			print(i + 1)
			break


n = int(input())
grades = list(map(int, input().split()))
grades.sort()
av_grade = sum(grades) / n
need = True
change = 0
if av_grade >= 4.5:
	av_grade = 5
if av_grade == 5:
	print(0)
	need = False
if need:
	for i in range(n):
		if sum(grades) / n < 4.5:
			rem = sum(grades) - grades[i]
			if 4.5 * n - rem > grades[i] and grades[i] != 5:
				grades[i] = 5
				change += 1
	print(change)


n = int(input())
item = list(map(int, input().split()))
s = sum(item)
item.sort()
a = s / n * 10 % 10
if a >= 5:
	t = s // n + 1
else:
	t = s // n
for i in range(n + 1):
	if t == 5:
		print(i)
		break
	else:
		item[i] = 5
		s = sum(item)
		a = s / n * 10 % 10
		if a >= 5:
			t = s // n + 1
		else:
			t = s // n


n = int(input())
marks = list(map(int, input().split()))
count = 0
mean = sum(marks) / n
while mean < 4.5:
	marks = sorted(marks)
	marks.pop(0)
	marks.append(5)
	mean = sum(marks) / n
	count += 1
print(count)


def test_2():
	import math
	from collections import Counter
	n = list(map(int, input().split(' ')))[0]
	data = list(map(int, input().split(' ')))
	data.sort()
	mean_1 = sum(data) / n
	if mean_1 < 4.5:
		diff = 4.5 - mean_1
		aa_1 = round(diff * n, 6)
		count = 0
		for i in range(len(data)):
			count += 5 - data[i]
			if count >= aa_1:
				print(i + 1)
				return
	else:
		print(0)
test_2()


n = float(input())
l = input().split()
l = list(map(int, l))
p = sorted(l)
a = float(sum(p))
avg = a / n
count = 0
if avg >= 4.5:
	print(count)
else:
	for i in p:
		a += 5 - i
		count += 1
		avg = a / n
		if avg >= 4.5:
			break
	print(count)


def test(l):
	s = 0
	for i in range(len(l)):
		s += l[i]
	s /= n
	if s >= 4.5:
		return 1
	else:
		return 0
n = int(input())
l = list(map(int, input().split()))
l = sorted(l)
c = 0
if test(l) == 1:
	print(0)
else:
	for i in range(n):
		if test(l) != 1:
			l[i] = 5
			c += 1
		else:
			break
	print(c)


R = lambda : map(lambda x: int(x) * 2, input().split())
n = int(input())
arr = list(R())
arr.sort()
ans = 0
s = sum(arr)
while s < 9 * n:
	s += 10 - arr[ans]
	ans += 1
print(ans)


import decimal
n = int(input())
g = input().split()
for x in range(n):
	g[x] = int(g[x])
g = sorted(g)
c = 0
for x in range(n):
	c = c + g[x]
dd = decimal.Decimal(c / n)
d = dd.quantize(decimal.Decimal('1'), rounding='ROUND_HALF_UP')
counter = 0
while d != 5:
	counter = counter + 1
	g[0] = 5
	g = sorted(g)
	c = 0
	for x in range(n):
		c = c + g[x]
	dd = decimal.Decimal(c / n)
	d = dd.quantize(decimal.Decimal('1'), rounding='ROUND_HALF_UP')
print(counter)


def read_input():
	return map(int, input().split())
n = int(input())
a = sorted(read_input())
s = sum(a)
i = 0
while 2 * s < 9 * n:
	delta = 5 - a[i]
	s += delta
	i += 1
print(i)


(n, a) = (int(input()), sorted([int(x) for x in input().split()]))
(s, t, i) = (sum(a), n * 4.5, 0)
for x in a:
	if s >= t:
		break
	(s, i) = (s + 5 - x, i + 1)
print(i)


from statistics import mean
n = int(input())
m = list(map(int, input().split()))

def roundTraditional(val, digits):
	return round(val + 10 ** (-len(str(val)) - 1), digits)
m.sort()
i = 0
while roundTraditional(mean(m), 0) < 5:
	m[i] = 5
	i += 1
print(i)


def check_avg(grades):
	total = sum(grades)
	avg = total / n
	if avg >= 4.5:
		return True
	else:
		return False
n = int(input())
grades = [int(x) for x in input().split()]
grades = sorted(grades)
count = 0
i = 0
while i < len(grades):
	if grades[i] == 5:
		i += 1
		continue
	elif check_avg(grades):
		break
	elif grades[i] != 5:
		grades[i] = 5
		count += 1
		i += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
x = s / n
if x >= 4.5:
	print(0)
else:
	z = 4.5 * n
	if z != int(z):
		z = int(z) + 1
	else:
		z = int(z)
	rem = z - s
	l = [5 - i for i in a]
	l.sort(reverse=True)
	c = 0
	ans = 0
	for i in l:
		c += i
		ans += 1
		if c >= rem:
			print(ans)
			break


n = int(input())
a = list(map(int, input().split()))
if sum(a) / len(a) >= 4.5:
	print(0)
else:
	a.sort(reverse=True)
	count = 0
	k = len(a)
	while sum(a) / len(a) < 4.5:
		k -= 1
		a[k] = 5
		count += 1
	print(count)


n = int(input())
a = list(map(int, input().split()))
s5 = 0
s4 = 0
s3 = 0
s2 = 0
count = 0
for i in range(n):
	if a[i] == 5:
		s5 += 1
	elif a[i] == 4:
		s4 += 1
	elif a[i] == 3:
		s3 += 1
	else:
		s2 += 1
while (s5 * 5 + s4 * 4 + s3 * 3 + s2 * 2) / n < 4.5:
	if s2 > 0:
		s2 -= 1
		s5 += 1
		count += 1
	elif s3 > 0:
		s3 -= 1
		s5 += 1
		count += 1
	else:
		s4 -= 1
		s5 += 1
		count += 1
print(count)


n = int(input())
grades = sorted([int(i) for i in input().split(' ')])
s = sum(grades)
i = 0
while s / len(grades) < 4.5:
	s += 5 - grades[i]
	i += 1
print(i)


from collections import defaultdict, deque, Counter
from sys import stdin, stdout
from heapq import heappush, heappop
import math
import io
import os
import math
import bisect

def isPrime(x):
	for i in range(2, x):
		if i * i > x:
			break
		if x % i == 0:
			return False
	return True

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def digits(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def ceil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def mapin():
	return map(int, input().split())

def solve(a, n):
	if n & 1:
		if a % n <= n // 2:
			return a // n
		else:
			return 1 + a // n
	elif a % n < n // 2:
		return a // n
	else:
		return 1 + a // n
n = int(input())
l = [int(x) for x in input().split()]
a = l.count(2)
b = l.count(3)
c = l.count(4)
temp = sum(l)
curr = solve(temp, n)
ans = 0
while curr != 5:
	if a > 0:
		a -= 1
		ans += 1
		temp += 3
		curr = solve(temp, n)
	elif b > 0:
		b -= 1
		ans += 1
		temp += 2
		curr = solve(temp, n)
	elif c > 0:
		c -= 1
		ans += 1
		temp += 1
		curr = solve(temp, n)
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
avg = sum(a) / n
a.sort()
count = 0
if avg < 4.5:
	for i in range(n):
		if avg < 4.5:
			avg = (sum(a) + (5 - a[i])) / n
			a[i] = 5
			count += 1
		else:
			break
print(count)


a = int(input())
l = list(map(int, input().split()))
b = sum(l)
b = 4.5 * a - b
if b > 0:
	if b == int(b):
		c = b
	else:
		c = int(b) + 1
	l.sort()
	l.reverse()
	j = 0
	while c > 0:
		c = c + l.pop() - 5
		j += 1
	print(j)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
sum = 0
for i in range(len(a)):
	sum += a[i]
a.sort()
i = 0
while sum / n < 4.5:
	sum += 5 - a[i]
	i += 1
print(i)


n = int(input())
marks = [int(x) for x in input().split()]
middle = sum(marks) / len(marks)
marks = sorted(marks)
i = 0
while middle < 4.5:
	marks[i] = 5
	middle = sum(marks) / len(marks)
	i += 1
print(i)


n = int(input())
s = list(map(int, input().split()))
s.sort()
su = sum(s)
ans = 0
if su / n < 4.5:
	for i in s:
		if i < 5:
			su += 5 - i
			ans += 1
		else:
			break
		if su / n >= 4.5:
			break
print(ans)


import sys
import math
import bisect

def query_grade(n, total):
	for i in range(5, 1, -1):
		if abs(i * n - total) <= abs((i - 1) * n - total):
			return i
	return -1

def solve(A):
	n = len(A)
	A.sort()
	total = sum(A)
	if query_grade(n, total) == 5:
		return 0
	for i in range(n):
		total += 5 - A[i]
		if query_grade(n, total) == 5:
			return i + 1
	return -1

def main():
	n = int(input())
	A = list(map(int, input().split()))
	ans = solve(A)
	print(ans)
main()


from math import ceil
N = int(input())
Grades = sorted(list(map(int, input().split())))
i = 0
SUM = sum(Grades)
Average = SUM / N
Average = round(Average) if Average - 0.5 != int(Average) else ceil(Average)
while Average != 5:
	SUM += 5 - Grades[i]
	Average = SUM / N
	Average = round(Average) if Average - 0.5 != int(Average) else ceil(Average)
	i += 1
print(i)


n = int(input())
grades = [int(i) for i in input().split()]
if sum(grades) / n < 4.5:
	grades.sort()
	j = 0
	for i in range(n):
		grades[i] = 5
		j += 1
		if sum(grades) / n >= 4.5:
			break
	print(j)
else:
	print(0)


n = int(input())
l = [int(x) for x in input().split()]
avg = sum(l) / n
add = sum(l)
l.sort()
if avg >= 4.5:
	print(0)
else:
	ans = 0
	for i in range(n):
		if l[i] < 5:
			add += 5 - l[i]
			ans += 1
		if add / n >= 4.5:
			print(ans)
			break


def func(ar, a):
	av = sum(ar) / len(ar)
	if av >= 4.5:
		return a
	else:
		ar[0] = 5
		a += 1
		ar.sort()
		return func(ar, a)
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
a = 0
print(func(arr, a))


from math import *
n = int(input())
arr = list(map(int, input().split()))
k = ceil(4.5 * n)
j = sum(arr)
if j >= k:
	print(0)
else:
	arr.sort()
	ans = 0
	z = 0
	while z < n and j < k:
		j -= arr[z]
		j += 5
		ans += 1
		z += 1
	print(ans)


n = int(input())
a = list(map(int, input().split()))
if round(sum(a) / n) == 5:
	print('0')
else:
	c = 0
	a.sort()
	x = 4.5 * n - sum(a)
	j = 0
	while x > 0 and j < n:
		x -= 5 - a[j]
		c += 1
		j += 1
	print(c)


n = int(input())
m = list(map(int, input().split()))
a = sum(m)
i = 0
l = []
for k in m:
	l.append(5 - k)
while True:
	if a / n >= 4.5:
		print('0')
		exit()
	elif (a + i) / n >= 4.5:
		break
	else:
		i += 1
l.sort(reverse=True)
b = 0
for j in range(n):
	b += l[j]
	if b >= i:
		print(j + 1)
		break


import argparse

def main():
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	total = sum(a)
	dis = 5 * n * 0.9 - total
	count = 0
	while dis > 0:
		dis -= 5 - a[count]
		count += 1
	print(count)
main()


n = int(input())
a = list(map(int, input().split()))
f = 0
while True:
	s = a[0]
	minn = a[0]
	k = 0
	for i in range(1, n):
		s += a[i]
		if a[i] < minn:
			minn = a[i]
			k = i
	sr = s / n
	if sr == 4.5:
		sr = 5
	if round(sr) == 5:
		print(f)
		break
	else:
		a[k] = 5
		f += 1


import sys
n = int(input())
a = [int(i) for i in input().split()]
s = sum(a) / n
q = sum(a)
c = 0
while s < 4.5:
	m = min(a)
	t = a.index(m)
	s = q - m + 5
	q = s
	s = s / n
	a[t] = sys.maxsize
	c += 1
print(c)


n = int(input())
arr = input().split(' ')
arr = [float(x) for x in arr]
sum_arr = sum(arr)
if sum_arr / n >= 4.5:
	print(0)
else:
	arr = sorted(arr)
	for i in range(n):
		if (sum_arr - arr[i] + 5) / n >= 4.5:
			print(i + 1)
			break
		else:
			sum_arr = sum_arr - arr[i] + 5


import statistics
n = int(input())
grades = list(map(int, input().split()))
grades.sort()
i = 0
count = 0
while statistics.mean(grades) < 4.5:
	grades[i] = 5
	count = count + 1
	i = i + 1
print(count)


s_min = 4.5 * int(input())
cal = [int(x) for x in input().split()]
s_obt = sum(cal)
cal.sort()
nt = 0
while s_min > s_obt:
	s_obt += 5 - cal[nt]
	nt += 1
print(str(nt))


n = int(input())
v = [int(i) for i in input().split()]
v = sorted(v)
cont = 0
soma = sum(v)
med = soma / n
id = 0
while med < 4.5:
	v[id] = 5
	id += 1
	cont += 1
	soma = sum(v)
	med = soma / n
print(cont)


class CodeforcesTask991BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.grades = []

	def read_input(self):
		self.n = int(input())
		self.grades = [int(x) for x in input().split(' ')]

	def process_task(self):
		work = 0
		ss = sum(self.grades)
		while round(ss / self.n + 1e-05) < 5:
			self.grades.sort()
			ss += 5
			ss -= self.grades[0]
			self.grades[0] = 5
			work += 1
		self.result = str(work)

	def get_result(self):
		return self.result
Solution = CodeforcesTask991BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


import math
n = int(input())
a = list(map(int, input().split()))
k = sum(a)
if k / n >= 4.5:
	print(0)
else:
	r = 4.5 * n
	t = r - k
	j = math.ceil(t)
	a.sort()
	count = 0
	for i in range(n):
		if j >= 5 - a[i]:
			j = j - (5 - a[i])
			a[i] = 5
			count += 1
		else:
			j = 0
			count += 1
		if j <= 0:
			print(count)
			break


def r(n):
	d = int(n)
	if n >= d + 0.5:
		return d + 1
	return d
import statistics as stats

def main():
	rd = lambda : list(map(int, input().split()))
	rd1 = lambda : int(input())
	n = rd1()
	arr = rd()
	arr.sort()
	m = r(stats.mean(arr))
	if m == 5:
		print(0)
		return
	else:
		cnt = 0
		for i in range(len(arr)):
			if arr[i] < 5:
				arr[i] = 5
				cnt += 1
				m = r(stats.mean(arr))
				if m == 5:
					print(cnt)
					return
		print(cnt)
main()


n = int(input().strip())
a = [int(_) for _ in input().strip().split()]
count = 0
while round(sum(a) / n + 1e-08) != 5:
	count += 1
	a[a.index(min(a))] = 5
print(count)


n = int(input())
ta = input().split()
a = []
for i in ta:
	a.append(int(i))
a.sort()
ans = 0
s = 0
for i in range(n - 1, -1, -1):
	s += 5 - a[i]
	if s * 2 > n:
		ans = i + 1
		break
print(ans)


def score(l):
	num = sum(l) / len(l)
	return int(num + 0.5)
n = int(input())
grades = [int(i) for i in input().split()]
grades.sort()
cnt = 0
i = 0
while i < n:
	s = score(grades)
	if s >= 5:
		break
	curr = grades[i]
	if curr != 5:
		grades[i] = 5
		cnt += 1
	i += 1
print(cnt)


n = int(input())
e = list(map(int, input().split()))
e.sort()
amo = 0
for i in e:
	amo = amo + i
amo = amo * 10
ans = 0
if amo >= 45 * n:
	print(0)
else:
	for i in e:
		amo = amo + 50 - i * 10
		ans = ans + 1
		if amo >= 45 * n:
			break
	print(ans)


def merge_sort(array):
	if len(array) == 1:
		return array
	arrayOne = [array[i] for i in range(0, int(len(array) / 2))]
	arrayTwo = [array[i] for i in range(int(len(array) / 2), len(array))]
	arrayOne = merge_sort(arrayOne)
	arrayTwo = merge_sort(arrayTwo)
	return merge(arrayOne, arrayTwo)

def merge(arrayA, arrayB):
	output = []
	while len(arrayA) > 0 and len(arrayB) > 0:
		if arrayA[0] > arrayB[0]:
			output.append(arrayB[0])
			arrayB.pop(0)
		else:
			output.append(arrayA[0])
			arrayA.pop(0)
	while len(arrayA) > 0:
		output.append(arrayA[0])
		arrayA.pop(0)
	while len(arrayB) > 0:
		output.append(arrayB[0])
		arrayB.pop(0)
	return output

def correct_grades():
	length = int(input())
	grades = list(map(int, input().split()))
	up = 4.5
	temp = sum(grades) / length
	if temp >= up:
		return 0
	output = 0
	grades = merge_sort(grades)
	for i in range(len(grades)):
		output += 1
		grades[i] = 5
		temp = sum(grades) / length
		if temp >= up:
			return output
A = correct_grades()
print(A)


n = int(input())
a = list(map(int, input().split()))
tot = sum(a)
a.sort()
cnt = 0
for i in range(n):
	if tot / n >= 4.5:
		print(cnt)
		exit(0)
	if a[i] < 5:
		cnt += 1
		tot += 5 - a[i]
print(cnt)


import math

def solve():
	n = int(input())
	sum = 0
	v = [int(x) for x in input().split(' ')]
	for x in v:
		sum = sum + x
	redo = max(0, math.ceil(n * 4.5) - sum)
	if redo == 0:
		return redo
	v.sort()
	count = 0
	for i in range(n):
		redo = redo - (5 - v[i])
		count = count + 1
		if redo <= 0:
			return count
print(solve())


n = int(input())
s = sorted(list(map(int, input().split())))
minimum = n * 4.5
current = sum(s)
count = 0
for i in range(n):
	if current >= minimum:
		break
	else:
		current += 5 - s[i]
		count += 1
print(count)


n = int(input())
l = [int(i) for i in input().split(' ')]
cg = sum(l) / n
if cg >= 4.5:
	print(0)
else:
	l.sort()
	s = sum(l)
	ans = 0
	for i in range(n):
		s += 5 - l[i]
		ans += 1
		if s / n >= 4.5:
			print(ans)
			break


n = int(input())
a = [int(x) for x in input().split()]
sum = 0
a = sorted(a)
for c in a:
	sum += c
avg = sum / n
count = 0
for c in a:
	if avg >= 4.5:
		break
	sum += 5 - c
	avg = sum / n
	count += 1
print(count)


def roundoff(n):
	if n % 1 >= 0.5:
		return int(n) + 1
	else:
		return int(n)
n = int(input())
grades = list(map(int, input().split()))
average = roundoff(sum(grades) / n)
moves = 0
if average == 5:
	print(0)
else:
	sumogrades = sum(grades)
	grades.sort()
	for i in grades:
		moves += 1
		sumogrades += 5 - i
		average = roundoff(sumogrades / n)
		if average == 5:
			break
	print(moves)


n = int(input())
m = list(map(int, input().split()))
j = 0
s = 0
for i in range(0, n):
	s += m[i]
k = s / n
while k < 4.5:
	mi = min(m)
	s = 0
	flag = False
	for i in range(0, n):
		s = s + m[i]
		if mi == m[i] and flag == False:
			m[i] = 5
			flag = True
	s = s - mi + 5
	k = s / n
	j = j + 1
print(j)


n = int(input().strip())
grades = list(map(int, input().strip().split()))
grades.sort()
total = sum(grades)
i = 0
while total < 4.5 * n:
	grades[i] = 5
	i += 1
	total = sum(grades)
print(i)


n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
total = sum(a)
req = 0
from math import ceil
if total / n >= 4.5:
	print(0)
	quit()
for i in a:
	total += 5 - i
	req += 1
	if total / n >= 4.5:
		break
print(req)


n = int(input())
l = [int(i) for i in input().split()]
diff = [0] * n
for i in range(n):
	diff[i] = 5 - l[i]
diff.sort(reverse=True)
req = n * 4.5
if sum(l) >= req:
	print(0)
else:
	curr = sum(l)
	cnt = 0
	i = 0
	while curr < req and i < n:
		cnt += 1
		curr += diff[i]
		i += 1
	print(cnt)


n = int(input())
grades = list(map(int, input().split()))
currSum = sum(grades)
currentAvg = currSum / n
grades.sort()
i = 0
while i < n:
	if currentAvg >= 4.5:
		break
	currSum = currSum - grades[i] + 5
	i += 1
	currentAvg = currSum / n
print(i)


n = int(input())
ai = list(map(int, input().split()))
ai.sort()
mean = sum(ai) / n
if mean >= 4.5:
	print(0)
else:
	cnt = 0
	for i in range(len(ai)):
		ai[i] = 5
		cnt += 1
		mean = sum(ai) / n
		if mean >= 4.5:
			break
	print(cnt)


n = int(input())
a = list(map(int, input().split()))
a.sort()
c = 0
while sum(a) / len(a) < 4.5:
	a[a.index(min(a))] = 5
	c += 1
print(c)


n = int(input())
a = sorted(map(int, input().split()))
s = sum(a)
for i in range(n):
	if s * 2 >= 9 * n:
		break
	s += 5 - a[i]
else:
	i = n
print(i)


n = int(input())
li = [int(x) for x in input().split()]
av = sum(li) / n
if av >= 4.5:
	print(0)
	exit()
else:
	two = li.count(2)
	three = li.count(3)
	four = li.count(4)
	five = li.count(5)
	ccc = 0
	while True:
		if two != 0:
			two -= 1
			five += 1
			ccc += 1
		elif three != 0:
			three -= 1
			five += 1
			ccc += 1
		else:
			four -= 1
			five += 1
			ccc += 1
		if (two * 2 + three * 3 + four * 4 + five * 5) / n >= 4.5:
			print(ccc)
			quit()


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if s / n >= 4.5:
	print(0)
else:
	a.sort()
	c = 0
	for i in a:
		if i == 5:
			break
		else:
			c += 1
			s += 5 - i
			if s / n >= 4.5:
				break
	print(c)


import atexit, io, sys
buffer = io.StringIO()
sys.stdout = buffer

@atexit.register
def write():
	sys.__stdout__.write(buffer.getvalue())
from sys import stdin, stdout

def main():
	s_min = 4.5 * int(stdin.readline())
	cal = [int(x) for x in stdin.readline().split()]
	s_obt = sum(cal)
	cal.sort()
	nt = 0
	while s_min > s_obt:
		s_obt += 5 - cal[nt]
		nt += 1
	stdout.write(str(nt))
main()


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
s = sum(arr)
if s / n >= 4.5:
	print(0)
else:
	c = 0
	for i in range(n):
		if arr[i] < 5:
			s += 5 - arr[i]
			arr[i] = 5
			c = c + 1
		if s / n >= 4.5:
			print(c)
			exit()


import math
n = int(input())
ls = sorted(list(map(int, input().split())))
s = sum(ls)
if s / n >= 4.5:
	print(0)
else:
	ch = math.ceil(4.5 * n)
	rm = ch - s
	c = 0
	for i in range(n):
		if rm - (5 - ls[i]) <= 0:
			c += 1
			break
		else:
			c += 1
			rm -= 5 - ls[i]
	print(c)


q = int(input())
w = list(map(int, input().split()))
v = 0
while sum(w) / len(w) < 4.5:
	d = min(w)
	f = 0
	for i in range(len(w)):
		if w[i] == d:
			f = i
			break
	w[f] = 5
	v += 1
print(v)


n = int(input())
a = list(map(int, input().split()))
a.sort()
d = 4.5 * n - sum(a)
ans = 0
while d > 0:
	d -= 5 - a[ans]
	ans += 1
print(ans)


n = int(input())
a = sorted(map(int, input().split()))
cnt = 0
while sum(a) * 2 < 9 * n:
	a = sorted(a)
	a[0] = 5
	cnt += 1
print(cnt)


n = int(input())
l1 = [int(x) for x in input().split()]
i = 0
while 2 * sum(l1) < 9 * n:
	l1.sort()
	l1[0] = 5
	i += 1
print(i)


n = int(input())
ar = list(map(int, input().split(' ')))
ar.sort()
t = 0
while sum(ar) < 4.5 * n:
	ar[t] = 5
	t += 1
print(t)


n = int(input())
a = list(map(int, input().split()))
a.sort()
t = 0
sm = sum(a)
while len(a) and int(sm / n + 0.5) != 5:
	sm += 5 - a[0]
	a.pop(0)
	t += 1
print(t)


import math
n = int(input())
grades = input().split(' ')
length = len(grades)
for i in range(length):
	grades[i] = int(grades[i])

def findmean(grad):
	mean = sum(grad) / len(grad)
	if mean - math.floor(mean) < 0.5:
		return math.floor(mean)
	else:
		return math.ceil(mean)
count = 0
while findmean(grades) < 5:
	count += 1
	minimum = min(grades)
	for i in range(length):
		if minimum == grades[i]:
			grades[i] = 5
			break
print(count)


n = int(input())
m = [int(i) for i in input().split()]
m.sort()
s = sum(m)
sr = s / n
i = 0
while sr < 4.5:
	s += 5 - m[i]
	m[i] = 5
	i += 1
	sr = s / n
print(i)


u = int(input())
t = input()
L = t.split()
for i in range(u):
	L[i] = int(L[i])
s = 0
x = 0
for i in range(len(L)):
	s = s + L[i]
avg = s * 1.0 / len(L)
if avg > 4.5:
	print(0)
else:
	L.sort()
	j = 0
	while avg < 4.5:
		s = s - L[j] + 5
		j = j + 1
		x = x + 1
		avg = s * 1.0 / len(L)
	print(x)


from __future__ import print_function
import sys
import math
import os.path
import random
from copy import deepcopy
from functools import reduce
from collections import Counter, ChainMap, defaultdict
from itertools import cycle, chain
from queue import Queue, PriorityQueue
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, nlargest, nsmallest
import bisect
from statistics import mean, mode, median, median_low, median_high
sys.setrecursionlimit(1000000000)

def log(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def ni():
	return map(int, input().split())

def nio(offset):
	return map(lambda x: int(x) + offset, input().split())

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

def toString(aList, sep=' '):
	return sep.join((str(x) for x in aList))

def toMapInvertIndex(aList):
	return {k: v for (v, k) in enumerate(aList)}

def sortId(arr):
	return sorted(range(arr), key=lambda k: arr[k])

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a
(n,) = ni()
a = nia()
a.sort()
mp = math.ceil(4.5 * n)
sa = sum(a)
count = 0
while sa < mp:
	sa += 5 - a[count]
	count += 1
print(count)


TN = 1

def solution():
	n = int(input())
	ots = list(map(int, input().split()))
	ans = 0
	if sum(ots) / n >= 4.5:
		ans = 0
	else:
		ots = sorted(ots)
		for i in range(1, n + 1):
			if (sum(ots[i:]) + len(ots[:i]) * 5) / n >= 4.5:
				ans = i
				break
	print(ans)
while TN != 0:
	solution()
	TN -= 1


def nround(r):
	if r % 1 == 0.5:
		return int(r) + 1
	else:
		return round(r)
n = int(input())
a = list(map(int, input().split()))
s = 0
q = 0
for i in range(n):
	s += a[i]
i = s / n
while nround(i) < 5:
	j = 5 - min(a)
	a[a.index(min(a))] = 5
	s += j
	i = s / n
	q += 1
print(q)


n = int(input())
L = list(map(int, input().split()))
s = 0
moy = sum(L) / n
L.sort()
while moy < 4.5:
	L[s] = 5
	s = s + 1
	moy = sum(L) / n
print(s)


n = int(input())
temp = [int(i) for i in input().split()]
temp = sorted(temp)
arr_sum = sum(temp)
max_sum = len(temp) * 4.5
get_sum = max_sum - arr_sum

def find_count(get_sum):
	if len(temp) == 1 and temp[0] < 5:
		return 1
	elif len(temp) == 1 and temp[0] == 5:
		return 0
	ex_sum = 0
	count = 0
	for i in range(len(temp) + 1):
		if ex_sum >= get_sum:
			return count
		ex_sum += 5 - temp[i]
		count += 1
print(find_count(get_sum))


n = int(input())
c = list(map(int, input().split()))
c = sorted(c)
r = sum(c)
if r / n >= 4.5:
	print(0)
else:
	index = 0
	tot = 0
	while r / n < 4.5:
		if c[index] < 5:
			r += 5 - c[index]
			tot += 1
		index += 1
		if r / n >= 4.5:
			break
	print(tot)


n = int(input())
a = sorted(list(map(int, input().split())))
summ = sum(a)
i = 0
while i < n:
	if summ / n >= 4.5:
		print(i)
		break
	summ += 5 - a[i]
	i += 1
else:
	print(n)


n = int(input())
a = list(map(int, input().split()))
ans = 0
while sum(a) / n < 4.5:
	i = 0
	while a[i] != min(a):
		i += 1
	a[i] = 5
	ans += 1
print(ans)


import math

def my_rounder(fl):
	fl_str = str(fl)
	index = fl_str.find('.')
	decimal = fl_str[index + 1:]
	int_decimal = int(decimal)
	int_part = int(fl_str[:index])
	thousand = int('1' + '0' * len(decimal))
	if thousand - int_decimal > int_decimal:
		return int_part
	return int_part + 1

def main_function():
	input()
	grades = sorted([int(i) for i in input().split(' ')])
	count = 0
	while not my_rounder(sum(grades) / len(grades)) == 5:
		grades[count] = 5
		count += 1
	return count
print(main_function())


n = int(input())
a = list(map(int, input().split()))
cur = sum(a)
if cur / n >= 4.5:
	print(0)
	exit(0)
a.sort()
ans = 0
for i in a:
	cur += 5 - i
	ans += 1
	if cur / n >= 4.5:
		print(ans)
		exit(0)


n = int(input())
a = [int(i) for i in input().split()]
av = sum(a)
x = 4.5 * n
c = 0
z = av - x
if z >= 0:
	print(0)
else:
	z = abs(z)
	a.sort()
	for i in a:
		if i != 5:
			k = 5 - i
			z = z - k
			c += 1
		if z <= 0:
			break
	print(c)


n = int(input())
ls = list(map(int, input().split()))
if sum(ls) / n >= 4.5:
	print(0)
else:
	ls.sort()
	k = 0
	cnt = 0
	while sum(ls) / n < 4.5:
		if ls[k] < 5:
			ls[k] = 5
		k += 1
		cnt = cnt + 1
	print(cnt)


n = int(input()) * 4.5
total = 0
entrada = []
for x in input().split():
	total += int(x)
	if int(x) < 5:
		entrada.append(int(x))
res = 0
entrada.sort()
while total < n:
	total += 5 - entrada[res]
	res += 1
print(res)


n = int(input())
a = list(map(int, input().split()))
ans = n
a = list(sorted(a))
s = [sum(a)]
for i in range(n):
	if 9 * n <= 2 * s[-1]:
		ans = i
		break
	s.append(s[-1])
	s[-1] -= a[i]
	s[-1] += 5
print(ans)


n = int(input())
l = list(map(int, input().split()))
mx = n * 45
l = [10 * i for i in l]
c = 0
while sum(l) < mx:
	c += 1
	l.sort()
	l[0] = 50
print(c)


input()
grades = list(sorted([int(x) for x in input().split(' ')], reverse=True))
subjects = 0
while sum(grades) / len(grades) < 4.5:
	subjects += 1
	grades.pop()
	grades.insert(0, 5)
print(subjects)


n = int(input())
grade = list(map(int, input().split()))
grade.sort()
margin = 4.5 * n
score = sum(grade)
cnt = 0
while score < margin:
	score += 5 - grade[0]
	grade.pop(0)
	cnt += 1
print(cnt)


n = int(input())
g = list(map(int, input().split()))
ave = sum(g) / n
count = 0
g.sort()
if ave < 4.5:
	for i in range(n):
		g[i] = 5
		count = count + 1
		ave = sum(g) / n
		if ave >= 4.5:
			break
print(count)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
a = [ai * 2 for ai in a]
s = sum(a)
t = 9 * n
a.sort()
c = 0
if s < t:
	for i in range(n):
		s += 10 - a[i]
		c += 1
		if s >= t:
			break
print(c)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
sys.setrecursionlimit(10000)

def read_int():
	return int(input())

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

@mt
def slv(N, V):
	V.sort()
	if sum(V) / N >= 4.5:
		return 0
	ans = 1
	while True:
		V.pop(0)
		V.append(5)
		if sum(V) / N >= 4.5:
			break
		ans += 1
	return ans

def main():
	N = read_int()
	V = read_float_n()
	print(slv(N, V))
main()


n = int(input())
arr = sorted(map(int, input().split()))
i = 0
while sum(arr) < 4.5 * n:
	arr[i] = 5
	i += 1
print(i)


from functools import reduce
n = int(input())
l = list(sorted(map(int, input().split())))
k = sum(l) / n
if k - int(k) >= 0.5 and int(k) == 4 or int(k) == 5:
	print(0)
else:
	for i in range(n):
		l[i] = 5
		k = sum(l) / n
		if k - int(k) >= 0.5 and int(k) == 4 or int(k) == 5:
			print(i + 1)
			break


n = int(input())
l = list(map(int, input().split()))
d = sum(l)
c = 0
a = 4.5 * n
if d < a:
	l.sort()
	for i in l:
		if i < 5:
			d = d - i + 5
			c = c + 1
			if d >= a:
				break
print(c)


def myround(x):
	if x % 10 >= 5:
		x += 10 - x % 10
	return x

def main():
	n = int(input())
	a = map(int, input().split())
	a = sorted(a)
	avg = 10 * sum(a) // len(a)
	ans = 0
	for i in range(len(a)):
		if myround(avg) == 50:
			break
		a[i] = 5
		ans += 1
		avg = 10 * sum(a) // len(a)
	print(ans)
main()


import heapq

def ans(arr):
	heapq.heapify(arr)
	count = 0
	avg = average(arr)
	while avg < 4.5:
		temp = heapq.heappop(arr)
		heapq.heappush(arr, 5)
		count += 1
		avg = average(arr)
	return count
	pass

def average(arr):
	count = 0
	for i in range(len(arr)):
		count += arr[i]
	return count / len(arr)
n = int(input())
arr = list(map(int, input().strip().split(' ')))
print(ans(arr))


a = input()
s = input().split()
d = []
for i in s:
	d.append(int(i))
if sum(d) / len(d) >= 4.5:
	print(0)
else:
	step = 0
	while sum(d) / len(d) < 4.5:
		d.remove(min(d))
		d.append(5)
		step += 1
	print(step)


import math
n = int(input())
g = [int(x) for x in input().split(' ')]
g.sort()
required = math.ceil(4.5 * n) - sum(g)
upgrades = 0
while required > 0:
	required -= 5 - g[upgrades]
	upgrades += 1
print(upgrades)


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().strip().split()))
avg = sum(a) / n
count = 0
if avg >= 4.5:
	print('0')
else:
	a.sort()
	i = 0
	while avg < 4.5:
		a[i] = 5
		count += 1
		avg = sum(a) / n
		i += 1
	print(count)


def check(suma, n):
	return suma * 10 >= n * 45
n = int(input())
grades = list(map(int, input().split()))
suma = 0
for i in grades:
	suma += i
grades.sort()
i = 0
while not check(suma, n):
	suma += 5 - grades[i]
	i += 1
print(i)


n = int(input())
r = 4.5 * n
t = sorted([int(i) for i in input().split()])
c = 0
s = sum(t)
while s < r:
	s += 5 - t[c]
	c += 1
print(c)


n = int(input())
count = 0
mark = list(map(int, input().split()))
mark.sort()
for k in range(n):
	if sum(mark) / len(mark) < 4.5:
		if mark[k] != 5:
			mark[k] = 5
			count += 1
	else:
		break
print(count)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	sa = sum(a)
	if sa * 2 >= 9 * n:
		return 0
	for i in range(n):
		sa += 5 - a[i]
		if sa * 2 >= 9 * n:
			return i + 1
print(main())


n = int(input())
a = [0] * (n + 2)
a = list(map(int, input().split()))
s = 0
for i in range(n):
	s += a[i]
s = s / n
k = 0
while s < 4.5:
	min = 0
	for i in range(n):
		if a[i] < a[min]:
			min = i
	a[min] = 5
	s = 0
	for i in range(n):
		s += a[i]
	s = s / n
	k += 1
print(k)


from math import sqrt, ceil

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
a = li()
s = 0
a.sort()
s1 = ceil(4.5 * n)
for i in range(n):
	s += a[i]
if s >= s1:
	print('0')
else:
	f = 0
	s1 -= s
	for i in range(n):
		s1 -= 5 - a[i]
		f += 1
		if s1 <= 0:
			break
	print(f)


import sys
n = int(input())
grades = list(map(int, input().split()))
count = 0
produce = sum(grades)
result = produce / n
result1 = produce // n
if result >= 4.5:
	print('0')
	sys.exit()
else:
	result2 = (4.5 - result) * n
grades.sort()
for i in grades:
	result3 = result2 - 5 + i
	if result3 <= 0.1:
		count += 1
		print(count)
		sys.exit()
	else:
		result2 = result3
		count += 1


n = int(input())
a = sorted(map(int, input().split()))
(r, s) = (n * 4.5, sum(a))
for i in range(n + 1):
	if r <= s:
		break
	r -= 5
	s -= a[i]
print(i)


import math
n = int(input())
a = sorted(list(map(int, input().split())))
target_sum = math.ceil(4.5 * n)
current_sum = sum(a)
(i, ans) = (0, 0)
while current_sum < target_sum:
	current_sum += 5 - a[i]
	i += 1
	ans += 1
print(ans)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
summ = sum(arr)
k = 0
while summ / n < 4.5:
	summ += 5 - arr[k]
	k += 1
print(k)


n = int(input().strip())
a = list(map(int, input().strip().split()))
s = sum(a)
a = sorted(a)
cnt = 0
for i in range(n):
	if s / n >= 4.5:
		cnt = i
		break
	a[i] = 5
	s = sum(a)
	if i == n - 1:
		cnt = n
print(cnt)


import math
n = int(input())
l = list(map(int, input().split()))
s = sum(l)
x = math.ceil(4.5 * n - s)
c = 0
if x > 0:
	while x > 0:
		c += 1
		p = min(l)
		x = x + p - 5
		l.remove(min(l))
else:
	x = 0
print(c)


n = int(input())
marks = list(map(int, input().split()))
marks.sort()
summary = sum(marks)
diff = summary / n
e = 1e-17
desire = 4.5
i = 0
while diff < desire and i < n:
	summary = summary + (5 - marks[i])
	diff = summary / n
	i += 1
print(i)


num = int(input())
arr = [0] * num
arr = input().split()
for i in range(num):
	arr[i] = int(arr[i])
possible = 4.5 * num
total = sum(arr)
if total > possible:
	print(0)
else:
	arr2 = [0] * num
	for i in range(num):
		arr2[i] = 5 - arr[i]
	arr2.sort(reverse=True)
	count = 0
	for t in range(num):
		if total >= possible:
			break
		total = total + arr2[t]
		count += 1
		if total >= possible:
			break
	print(count)


n = int(input().strip())
border = 45 * n
grades = [10 * x for x in sorted(map(int, input().strip().split()))]
counter = 0
while sum(grades) < border:
	grades[counter] = 50
	counter += 1
print(counter)


n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ans = 0
flag = 0
avg = sum(a) / n
if avg < 4.5:
	for i in range(n):
		a[i] = 5
		avg = sum(a) / n
		ans += 1
		if avg >= 4.5:
			break
	print(ans)
else:
	print(0)


n = int(input())
x = list(map(int, input().split()))
cnt = 0
x.sort()
for i in range(n):
	if sum(x) / n < 4.5:
		cnt += 1
		x[i] = 5
	else:
		break
print(cnt)


num = int(input())
arr = sorted(map(int, input().split()), reverse=True)
needed = 4.5 * num
earned = sum(arr)
ans = 0
while earned < needed:
	x = arr.pop()
	earned += 5 - x
	ans += 1
print(ans)


x = 4.5 * int(input())
A = sorted(map(int, input().split()))
s = sum(A)
k = 0
for a in A:
	if s >= x:
		break
	s += 5 - a
	k += 1
print(k)


d = int(input())
e = [int(x) for x in input().split()]
k = sorted(e)
(g, f) = (sum(e), 0)
for i in k:
	if i != 5 and g / d < 4.5:
		f += 1
		g += 5 - i
print(f)


n = int(input())
grades = [int(x) * 2 for x in input().split()]
res = sum(grades)
target = 9 * len(grades)
grades.sort()
for (i, grade) in enumerate(grades):
	if res >= target:
		print(i)
		break
	else:
		res += 10 - grade
else:
	print(len(grades))


n = int(input())
l = input().split()
z = 0
for i in range(n):
	l[i] = int(l[i])
	z += l[i]
l.sort()
prosjek = z / n
if prosjek >= 4.5:
	print('0')
else:
	i = 0
	z = 0
	while prosjek < 4.5:
		l[i] = 5
		for j in range(n):
			z += l[j]
		prosjek = z / n
		i += 1
		z = 0
	print(i)


a = int(input())
b = list(map(int, input().split()))
aim = a * 4.5
b.sort()
sum_all = sum(b)
ans = 0
if sum_all >= aim:
	print(0)
	exit()
for i in b:
	tmp = 5 - i
	sum_all += tmp
	ans = ans + 1
	if sum_all >= aim:
		print(ans)
		exit()


n = int(input().strip())
labs = list(map(int, input().strip().split()))
avg = sum(labs) / len(labs)
if avg >= 4.5:
	print(0)
else:
	min_redo = 0
	while avg < 4.5:
		min_redo += 1
		(min_lab, min_index) = (6, -1)
		for i in range(len(labs)):
			if labs[i] < min_lab:
				(min_lab, min_index) = (labs[i], i)
		labs[min_index] = 5
		avg = sum(labs) / len(labs)
	print(min_redo)


(n, a) = (int(input()), sorted(map(int, input().split())))
(s, ans) = (sum(a) - n * 4.5, 0)
while s < 0:
	s += 5 - a[ans]
	ans += 1
print(ans)


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	add = sum(arr)
	if add / n >= 4.5:
		print(0)
		return
	arr.sort()
	for i in range(n):
		add += 5 - arr[i]
		if add / n >= 4.5:
			print(i + 1)
			return
main()


def hal(x):
	return 5 - x
n = int(input())
a = list(map(int, input().split()))
s = 0
h = 0
for i in range(0, n):
	h = h + a[i]
if n % 2 == 0:
	s = n * 4.5
else:
	s = n * 4.5 + 0.5
s = int(s)
for i in range(0, n):
	a[i] = hal(a[i])
a.sort(reverse=True)
i = 0
while s > h:
	h = h + a[i]
	i += 1
print(i)


n = int(input())
s = list(map(int, input().split()))
sm = sum(s)
s.sort()
x = 0
while sm / n < 4.5:
	sm -= s[x]
	sm += 5
	x += 1
print(x)


n = int(input())
a = sorted(list(map(int, input().split())))
for i in range(n + 1):
	cur_sum = 5 * i + sum(a[i:])
	if cur_sum * 10 >= n * 45:
		print(i)
		break


from math import *
n = int(input())
l = list(map(int, input().split()))
m = []
su = sum(l)
for i in l:
	m.append(5 - i)
m.sort(reverse=True)
if su < 4.5 * n:
	for i in range(n):
		su = su + m[i]
		if su >= 4.5 * n:
			print(i + 1)
			break
else:
	print('0')


def binSer(string, x):
	mid = len(string) // 2
	if string[mid] == x:
		return 1
	if ord(string[mid]) < ord(x):
		for i in string[mid + 1:]:
			if i == x:
				return 1
		return -1
	if ord(string[mid]) > ord(x):
		for i in string[:mid]:
			if i == x:
				return 1
		return -1

def solve():
	n = int(input())
	array = [int(i) for i in input().split()]
	sum = 0
	for i in array:
		sum += i
	if sum / n - 4 >= 0.5:
		return 0
	array.sort()
	(count, i) = (0, 0)
	while sum / n - 4 < 0.5 and i < n:
		sum += 5 - array[i]
		if 5 - array[i] != 0:
			count += 1
		i += 1
	return count
print(solve())


from math import ceil

def ur(n):
	if n + 0.5 >= int(n) + 1:
		return int(n) + 1
	else:
		return int(n)
n = int(input())
l = sorted(list(map(int, input().split())))
i = 0
while sum(l) < 4.5 * n:
	l[i] = 5
	i += 1
print(i)


s = int(input())
w = [int(x) for x in input().split()]
w = sorted(w)
suma = 0
for i in w:
	suma += i
we = 0
for (i, l) in enumerate(w):
	if suma / s >= 4.5:
		break
	suma += 5 - l
	we += 1
print(we)


import sys
a = sys.stdin.read()
a = a.split()
works = a[1:]
num = int(a[0])
for i in range(len(works)):
	works[i] = int(works[i])

def sum1(list1):
	su = 0
	for i in list1:
		su += int(i)
	return su

def compare(num):
	if num - int(num) >= 0.5:
		return int(num) + 1
	else:
		return int(num)
grade = compare(sum1(works) / num)
count = 0
while grade != 5:
	x = min(works)
	pos = works.index(x)
	works[pos] = 5
	count += 1
	grade = compare(sum1(works) / num)
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
i = 0
ari = sum(a) / len(a)
if ari >= 4.5:
	print(0)
else:
	while ari < 4.5:
		a[i] = 5
		ari = sum(a) / len(a)
		i += 1
	print(i)


from sys import stdin, stdout
n = int(stdin.readline())
values = sorted(list(map(int, stdin.readline().split())))
(l, r) = (-1, n)
while r - l > 1:
	m = l + r >> 1
	if (sum(values[m:]) + 5 * m) * 10 >= 45 * n:
		r = m
	else:
		l = m
stdout.write(str(r))


n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
c = sum(a)
d = 4.5 * n
k = 0
l = 0
for i in range(n):
	if c >= d:
		break
	else:
		k += 1
		c += 5 - b[l]
		l += 1
print(k)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
ans = 0
while 2 * s / n < 9:
	m = min(a)
	a.remove(m)
	a.append(5)
	s += 5 - m
	ans += 1
print(ans)


import sys
import collections
import math
import itertools as it

def readArray(type=int):
	line = input()
	return [type(x) for x in line.split()]

def getFreq(arr):
	freq = collections.defaultdict(int)
	for x in arr:
		freq[x] += 1
	return freq

def calcGrade(total, n):
	avg = round(0.001 + total / n)
	return int(avg)

def solve():
	n = int(input())
	arr = readArray()
	cc = 0
	arr.sort()
	total = sum(arr)
	grade = calcGrade(total, n)
	for (i, x) in enumerate(arr):
		if grade == 5:
			break
		total -= x
		total += 5
		grade = calcGrade(total, n)
		cc += 1
	print(cc)
solve()


n = int(input())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
x = sum(arr)
ans = 0
while x < 4.5 * n:
	x += 5 - arr[-1]
	arr.pop()
	ans += 1
print(ans)


def my_round(n):
	if n - int(n) >= 0.5:
		return int(n) + 1
	else:
		return int(n)
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
while my_round(sum(a) / n) < 5:
	a[0] = 5
	a.sort()
	ans += 1
print(ans)


n = int(input())
a = sorted([int(item) for item in input().split()])
s = sum(a)
i = 0
In = False
while s < 4.5 * n:
	In = True
	s += 1
	a[i] += 1
	if a[i] == 5:
		i += 1
		In = False
else:
	if In:
		i += 1
print(i)


tope = 5
n = int(input())
a = [int(x) for x in input().strip().split(' ')]
a_tam = len(a)
assert a_tam == n
min_necesario = 4.5 * a_tam
suma_actual = sum(a)
faltante = min_necesario - min(min_necesario, suma_actual)
r = 0
a = list(sorted(a))
while faltante:
	assert r < a_tam
	faltante -= min(faltante, tope - a[r])
	r += 1
print('{}'.format(r))


from math import *
n = int(input())
A = list(map(int, input().split()))
x = sum(A) / len(A)
a = 0
if x + 0.5 == ceil(x) and (x - 0.5) % 2 == 0:
	x = ceil(x)
else:
	x = round(x)
while round(x) != 5:
	A[A.index(min(A))] = 5
	x = sum(A) / len(A)
	a += 1
	if x + 0.5 == ceil(x) and (x - 0.5) % 2 == 0:
		x = ceil(x)
	else:
		x = round(x)
print(a)


def main():
	n = int(input())
	grades = [int(c) for c in input().split()]
	grades.sort()
	s = sum(grades)
	ans = 0
	target = 4.5 * n
	while s < target:
		s += 5 - grades[ans]
		ans += 1
	print(ans)
main()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
a = list(map(int, input().split()))
maximum = [5 - i for i in a if 5 - i > 0]
maximum.sort(reverse=1)
s = sum(a)
avg = s / n
if avg < 4.5:
	while avg < 4.5:
		s += 1
		avg = s / n
	(need, count) = (s - sum(a), 0)
	for i in range(len(maximum)):
		if need >= maximum[i]:
			need -= maximum[i]
			count += 1
		elif need < maximum[i]:
			break
	print(count if need <= 0 else count + 1)
else:
	print(0)


n = input()
grades = [int(x) for x in input().split()]
count = 0
mean = int(sum(grades) / len(grades) + 0.5)
while mean < 5:
	count += 1
	grades[grades.index(min(grades))] = 5
	mean = int(sum(grades) / len(grades) + 0.5)
print(count)


n = int(input()) * 4.5
entrada = [int(n) for n in input().split()]
entrada.sort()
total = sum(entrada)
res = 0
while total < n:
	total += 5 - entrada[res]
	res += 1
print(res)


n = int(input())
i = []
for a in input().split():
	i.append(int(a))
sr = sum(i) / len(i)
ans = 0
if sr >= 4.5:
	print(0)
else:
	while sr < 5:
		ans += 1
		i.remove(min(i))
		i.append(5)
		sr = round(sum(i) / len(i))
		if sum(i) / len(i) == 4.5 and sr == 4:
			sr = 5
	else:
		print(ans)


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
d = n * 4.5
req = d - s
a.sort()
cnt = 0
i = 0
while req > 0:
	req -= 5 - a[i]
	cnt += 1
	i += 1
print(cnt)


import math

def avog(grad, n):
	avg = sum(grad) / n
	(frac, whole) = math.modf(avg)
	if frac >= 0.5:
		avg = whole + 1
	else:
		avg = whole
	return avg
n = int(input())
grad = list(input().split())
for i in range(len(grad)):
	grad[i] = int(grad[i])
grad.sort()
avg = avog(grad, n)
if avg == 5.0:
	print('0')
else:
	i = 0
	while avg != 5.0 and i < n:
		grad[i] = 5.0
		avg = avog(grad, n)
		i = i + 1
	print(i)


n = int(input())
a = sorted(map(int, input().split()))
cur = sum(a)
target = (n * 9 + 1) // 2
redo = 0
while cur < target:
	cur += 5 - a[redo]
	redo += 1
print(redo)


TestCases = int(input())
Labs = list(map(int, input().split()))
Labs.sort()
TotalSum = sum(Labs)
if TotalSum / TestCases >= 4.5:
	print(0)
else:
	Mycounter = 0
	Needed = 4.5 * TestCases - TotalSum
	for i in range(TestCases):
		Mycounter += 1
		Needed -= 5 - Labs[i]
		if Needed <= 0:
			print(Mycounter)
			break


n = int(input())
g = list(map(int, input().split()))
ans = 0
gr = sum(g) / n
while gr < 4.5:
	ma = min(g)
	i = g.index(ma)
	g[i] = 5
	gr = sum(g) / n
	ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
su = sum(a)
c = int()
a.sort()
sr = su / n
while sr < 4.5:
	su -= a[c] - 5
	sr = su / n
	c += 1
print(c)


from collections import Counter
n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
total = 0
s = sum(arr)
p = 0
while s < 4.5 * n:
	s += 5 - arr[p]
	p += 1
	total += 1
print(total)


n = int(input())
u = list(map(int, input().split()))
s1 = 4.5 * n
if s1 % 1 != 0:
	s1 //= 1
	s1 += 1
s2 = sum(u)
u.sort()
ans = 0
ind = 0
while s2 < s1:
	s2 += 5 - u[ind]
	ind += 1
	ans += 1
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
s = 0
for i in a:
	s += i
k = 0
for i in a:
	if s >= 4.5 * n:
		break
	s += 5 - i
	k += 1
print(k)


import math
n = int(input())
s = input().split(' ')
arr = [int(s[i]) for i in range(n)]
num = {i: 0 for i in range(2, 6)}
for i in range(n):
	num[arr[i]] += 1

def sum(num):
	res = 0
	for i in range(2, 6):
		res += i * num[i]
	return res
diff = 4.5 * n - sum(num)
res = 0
if diff < 0:
	print(0)
else:
	for i in range(2, 6):
		if num[i] == 0:
			continue
		x = (5 - i) * num[i]
		if diff > x:
			num[5] += num[i]
			res += num[i]
			num[i] = 0
			diff -= x
		else:
			y = math.ceil(diff / (5 - i))
			res += y
			break
	print(res)


import math
n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
s = math.ceil(4.5 * n)
ss = sum(a)
c = 0
if ss >= s:
	print(0)
else:
	for i in a:
		if ss + (5 - i) >= s:
			c += 1
			break
		else:
			c += 1
			ss += 5 - i
	print(c)


n = int(input())
a = [int(m) * 2 for m in input().split()]
ans = sum(a)
a.sort()
i = 0
while ans < 9 * n:
	ans = ans + (10 - a[i])
	i += 1
print(i)


import math
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
marks = math.ceil(4.5 * n)
m = sum(l)
c = 0
for x in l:
	if m >= marks:
		break
	else:
		m += 5 - x
		c += 1
print(c)


n = int(input())
a = [int(x) for x in input().split()]
a = sorted(a)
greedy = 0
s = sum(a)
done = False
avg = s / n
if avg >= 4.5:
	done = True
for m in a:
	if done:
		break
	if m != 5:
		greedy += 1
	to_be_added = 5 - m
	s += to_be_added
	avg = s / n
	if avg >= 4.5:
		break
print(greedy)


n = int(input())
numbers = sorted(list(map(int, input().split(' '))))
redo = 0

def average():
	return sum(numbers) / n
while average() < 4.5:
	redo += 1
	if numbers[redo - 1] < 5:
		numbers[redo - 1] = 5
print(redo)


t = int(input())
l = list(map(int, input().split()))
l.sort()
i = 0
summ = 0
for i in l:
	summ += i
i = 0
while summ * 10 < 45 * t and i < t:
	summ = summ + (5 - l[i])
	i += 1
print(i)


def check(sums, n):
	return sums * 10 >= 45 * n
n = int(input())
scores = list(map(int, input().split()))
scores.sort()
sums = sum(scores)
ans = 0
while not check(sums, n):
	sums += 5 - scores[ans]
	ans += 1
print(ans)


n = int(input())
nums = list(map(int, input().split()))
total = sum(nums)
if n * 4.5 <= total:
	print(0)
else:
	nums.sort()
	queue = []
	for num in nums:
		if num < 5:
			queue.append(num)
		if num == 5:
			break
	count = 0
	while 0 < len(queue):
		tmp = queue.pop(0)
		count += 1
		total += 5 - tmp
		if 4.5 * n <= total:
			print(count)
			exit()


n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
a.sort()
ans = 0
while s < 4.5 * n:
	s += 5 - a[ans]
	ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
gr = 0
for i in a:
	gr += i
gr /= len(a)
count = 0
while gr < 4.5:
	j = 0
	while a[j] == 5:
		j += 1
	a[j] = 5
	gr = 0
	for i in a:
		gr += i
	gr /= len(a)
	count += 1
print(count)


n = int(input())
scores = list(map(int, input().strip().split()))
scores = sorted(scores)
goal = n * 4.5
summ = 0
for i in range(n):
	summ += scores[i]
res = -1
for i in range(n):
	if summ >= goal:
		res = i
		break
	else:
		summ = summ - scores[i] + 5
if res == -1:
	print(n)
else:
	print(res)


N = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
count = 0
for i in range(N):
	if sum(a) / N >= 4.5:
		break
	a[i] = 5
	count += 1
print(count)


N = int(input())
(*A,) = list(map(int, input().split()))
su = sum(A)
if su * 2 >= 9 * N:
	print(0)
	return
A.sort()
for i in range(N):
	su += 5 - A[i]
	if su * 2 >= 9 * N:
		print(i + 1)
		return
return


def main():
	n = int(input())
	l = list(map(int, input().split()))
	s = sum(l)
	c = 0
	while s / n < 4.5:
		t = min(l)
		l.remove(min(l))
		l.append(5)
		s -= t
		s += 5
		c += 1
	print(c)
main()


n = int(input())
a = list(map(int, input().split()))
a.sort()
sm = sum(a)
if sm / n >= 4.5:
	print(0)
	exit()
ans = 0
for i in range(n):
	if a[i] < 5:
		dif = 5 - a[i]
		sm += dif
		ans += 1
	if sm / n >= 4.5:
		break
print(ans)


from sys import *
from statistics import mean
import math
input = stdin.readline
listInput = lambda : list(map(int, input().strip().split()))
lineInput = lambda : map(int, input().strip().split())
sJoin = lambda a, sep: f'{sep}'.join(a)
arrJoin = lambda a, sep: f'{sep}'.join(map(str, a))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def main():
	c = 0
	n = int(input())
	arr = sorted(listInput())
	for i in range(n + 1):
		if 4.5 <= mean(arr) <= 5:
			print(c)
			return
		else:
			arr[i] = 5
			c += 1
main()


t = 1
while t:
	t -= 1
	n = int(input())
	ls = list(map(int, input().split()))
	ls.sort()
	s = sum(ls)
	if s / n >= 4.5:
		print(0)
		continue
	res = 0
	for item in ls:
		s += 5 - item
		res += 1
		if s / n >= 4.5:
			print(res)
			break


MIS = lambda : map(int, input().split())
n = int(input())
L = sorted(MIS())
for i in range(n):
	if sum(L) * 2 >= 9 * n:
		print(i)
		break
	L[i] = 5
else:
	print(n)


n = int(input())
grade = list(map(int, input().split()))
grade.sort()
gap = n * 4.5 - sum(grade)
cnt = 0
while gap > 0:
	gap -= 5 - grade[cnt]
	cnt += 1
print(cnt)


n = int(input())
grades = list(map(int, input().split()))
grades.sort()
required = 4.5
redo = 0
i = 0
while round(sum(grades) / n, 2) < required:
	redo = redo + 1
	grades[i] = 5
	i = i + 1
print(redo)


def solve(labs):
	if sum(labs) >= len(labs) * 4.5:
		return 0
	labs = sorted(labs)
	for i in range(len(labs)):
		labs = labs[:i] + [5] + labs[i + 1:]
		if sum(labs) >= len(labs) * 4.5:
			return i + 1
labs_count = int(input())
labs = list(map(int, input().split()))
print(solve(labs))


n = int(input())
a = [int(i) for i in input().split()]
sum = 0
a.sort()
for i in range(n):
	sum += a[i]
cnt = 0
for i in range(n):
	if sum / n >= 4.5:
		break
	sum += 5 - a[i]
	cnt += 1
print(cnt)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
count = 0
l = 0
while sum(arr) / n < 4.5:
	arr[l] = 5
	l += 1
	count += 1
print(count)


n = int(input())
grades = list(map(int, input().split()))
sumOfGrades = sum(grades)
answer = 0
grades.sort()
length = len(grades)
while sumOfGrades / length < 4.5:
	sumOfGrades += 5 - grades[answer]
	answer += 1
print(answer)


n = int(input())
query = list(map(int, input().split()))
grades = [0, 0, 0, 0]

def solution(grades, n):
	for x in query:
		grades[x - 2] += 1
	ave = (grades[0] * 2 + grades[1] * 3 + grades[2] * 4 + grades[3] * 5) / n
	if ave >= 4.5:
		return 0
	else:
		temp = grades[0] * 3 / n + ave
		if temp >= 4.5:
			return int((4.5 - ave) * n / 3 + 0.99)
		tempn = temp + grades[1] * 2 / n
		if tempn >= 4.5:
			return grades[0] + int((4.5 - temp) * n / 2 + 0.99)
		return grades[1] + grades[0] + int((4.5 - tempn) * n + 0.99)
print(solution(grades, n))


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
x = 4.5 * n - s
if x <= 0:
	print(0)
else:
	l = sorted(l)
	for i in range(n):
		r = 5 * (i + 1) - sum(l[:i + 1])
		if r >= x:
			print(i + 1)
			break


N = int(input())
n = list(map(int, input().split()))
S = 0
g = 4.5
k = 0
z = 0
x = 0
c = 0
for i in range(N):
	S += n[i]
	if n[i] == 2:
		z = 1
	if n[i] == 3:
		x = 1
	if n[i] == 4:
		c = 1
if S / N < g and z == 1:
	for i in range(N):
		if n[i] == 2:
			S += 3
			n[i] = 5
			k += 1
			if S / N >= g:
				u = 1
				break
if S / N < g and x == 1:
	for i in range(N):
		if n[i] == 3:
			S += 2
			n[i] = 5
			k += 1
			if S / N >= g:
				break
if S / N < g and c == 1:
	for i in range(N):
		if n[i] == 4:
			S += 1
			n[i] = 5
			k += 1
			if S / N >= g:
				break
print(k)


n = int(input())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
	b = int(sum(a) / n + 0.5)
	if b == 5:
		break
	else:
		a[i] = 5
		ans += 1
print(ans)


n = int(input().strip())
a = [int(x) for x in input().strip().split(' ')]
v = 4.5 * n
s = 0
b = []
for i in a:
	s += i
	b.append(5 - i)
b.sort(reverse=True)
c = 0
while s < v:
	s += b[c]
	c += 1
print(c)


n = int(input())
arr = list(map(int, input().strip().split()))
arr.sort()
avg = sum(arr) / n
if avg >= 4.5:
	print(0)
else:
	sum1 = sum(arr)
	count = 0
	for i in arr:
		sum1 -= i
		sum1 += 5
		count += 1
		if sum1 / n >= 4.5:
			break
	print(count)


n = int(input())
lis = []
lis = list(map(int, input().split()))
su = 0
for i in range(n):
	su += lis[i]
diff = []
for i in range(n):
	diff.append(5 - lis[i])
diff.sort()
count = 0
if su / n >= 4.5:
	print('0')
else:
	hh = su
	i = n - 1
	while hh / n < 4.5 and i >= 0:
		hh += diff[i]
		count += 1
		i -= 1
	print(count)


N = int(input())
a = list(map(int, input().split()))
a = sorted(a)
ave = sum(a) / N
i = 0
while ave < 4.5:
	moto = a[i]
	a[i] = 5
	i += 1
	ave = sum(a) / N
print(i)


def main():
	n = int(input())
	g = [int(i) for i in input().split(' ')]
	if sum(g) / n >= 4.5:
		print(0)
	else:
		g.sort()
		for i in range(n):
			g[i] = 5
			if sum(g) / n >= 4.5:
				print(i + 1)
				break
main()


b = 0
x = 0
c = 0
n = int(input())
l = list(map(int, input().split()))
l.sort()
for i in l:
	x += i
for i in l:
	if x / len(l) >= 4.5:
		print(c)
		b = 1
		break
	c += 1
	x += 5 - i
if b == 0:
	print(len(l))


n = int(input())
L = []
L = input().split()
L = [int(i) for i in L]
b = 0
s = sum(L)
l = len(L)
L.sort()
a = s / l
while a < 4.5:
	b += 1
	L[0] = 5
	L.sort()
	a = sum(L) / len(L)
print(b)


n = int(input())
a = list(map(int, input().split()))
c = [0, 0, 0, 0, 0, 0]
for _ in a:
	c[_] += 1
s = sum(a)
ans = 0
while 2 * s < 9 * n:
	if c[2] > 0:
		s += 3
		c[2] -= 1
		c[5] += 1
		ans += 1
	elif c[3] > 0:
		s += 2
		c[3] -= 1
		c[5] += 1
		ans += 1
	elif c[4] > 0:
		s += 1
		c[4] -= 1
		c[5] += 1
		ans += 1
print(ans)


n = int(input())
mark = list(map(int, input().split()))
mark.sort()
ans = 0
if round(sum(mark) / n + 1e-05) == 5:
	print(0)
	exit()
else:
	for i in range(n):
		mark[i] = 5
		ans += 1
		if round(sum(mark) / n + 1e-06) == 5:
			print(ans)
			break


n = int(input())
a = list(map(int, input().strip().split()))[:n]
x = sum((ele for ele in a))
cnt = 0
a.sort()
for i in range(0, len(a)):
	if x * 2 >= 9 * n:
		break
	if a[i] != 5:
		x -= a[i]
		a[i] = 5
		x += a[i]
		cnt += 1
print(cnt)


n = int(input())
L = [int(x) for x in input().split()]
L.sort()
s = sum(L)
total = 0
index = 0
while 2 * s < 9 * n:
	if L[index] != 5:
		s += 5 - L[index]
		total += 1
	index += 1
print(total)


grades = int(input())
k = sorted(map(int, input().split()))
count = 0
supposed = 4.5 * grades
diff = supposed - sum(k)
if diff <= 0:
	print(0)
else:
	for i in range(grades):
		if diff > 0:
			diff = diff - (5 - k[i])
			count = count + 1
		else:
			break
	print(count)


N = int(input())
marks = [int(x) for x in input().split()]
count = 0
minn = 10
while True:
	avg = sum(marks) / N
	if avg >= 4.5:
		print(count)
		break
	for i in range(N):
		if marks[i] < minn:
			minn = marks[i]
			index = i
	marks[index] = 5
	minn = 10
	count += 1


def round(n):
	if n >= int(n) + 0.5:
		return int(n + 1)
	return int(n)
n = int(input())
l = list(map(int, input().split()))
l.sort()
(count, x) = (0, 0)
while True:
	if round(sum(l) / n) == 5:
		print(count)
		break
	if l[x] != 5:
		l[x] = 5
		count += 1
	x += 1


n = int(input())
l = list(map(int, input().split()))
avg = sum(l) / n
if avg < 4.5:
	count = 0
	while avg < 4.5:
		l.remove(min(l))
		l.append(5)
		avg = sum(l) / n
		count += 1
	print(count)
else:
	print(0)


n = int(input())
grades = list(map(float, input().split()))
sum_present = sum(grades)
sum_average = 4.5 * n
count = 0
while sum_present < sum_average:
	sum_present += 5 - min(grades)
	grades[grades.index(min(grades))] = 5
	count += 1
print(count)


from math import *
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
s = 0
c = 0
for i in range(n):
	s += a[i]
while s / n < 4.5:
	s += 5 - a[c]
	c += 1
print(c)


n = int(input())
seq = input().split()
average = 0
for i in range(n):
	seq[i] = int(seq[i])
	average += seq[i]
average /= n
seq.sort()
cnt = 0
while average + 1e-08 < 4.5:
	average = average + (5 - seq[cnt]) / n
	cnt += 1
print(cnt)


import math
practicals = int(input())
practical_mark = list(map(int, input().split()))
sum_need = 4.5 * practicals
total = 0
changes_needed = 0
count_marks = [0, 0, 0, 0]
for each in practical_mark:
	ele = abs(2 - each)
	count_marks[ele] += 1
	total += each
if total < sum_need:
	point = 0
	add = 3
	while total < sum_need:
		if count_marks[point] == 0:
			point = point + 1
			add -= 1
		else:
			count_marks[point] -= 1
			total += add
			changes_needed += 1
print(changes_needed)


n = int(input())
arr = [int(i) for i in input().split()]
sum_arr = sum(arr)
arr.sort()
(res, i) = (0, 0)
while sum_arr / n < 4.5:
	res += 1
	while arr[i] < 5 and sum_arr / n < 4.5:
		arr[i] += 1
		sum_arr += 1
	i += 1
print(res)


import math
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
mn = s / n
if mn >= 4.5:
	print(0)
	exit()
a.sort()
ans = 0
for i in a:
	if i != 5:
		s += 5 - i
		ans += 1
		mn = s / n
	if mn >= 4.5:
		print(ans)
		exit()


n = int(input())
arr = sorted(list(map(int, input().split())))
ans = sum(arr)
if ans / n >= 4.5:
	print(0)
	exit()
for i in range(n):
	ans -= arr[i]
	ans += 5
	if ans / n >= 4.5:
		print(i + 1)
		break


n = int(input())
a = sorted(list(map(int, input().split())))
for i in range(-1, n):
	if (i + 1) * 5 + sum(a[i + 1:]) >= 4.5 * n:
		print(i + 1)
		exit()


n = int(input())
a = list(map(int, input().split()))
s = 0
for t in a:
	s += t
a.sort()
i = 0
while i < n and 2 * s < 9 * n:
	s += 5 - a[i]
	i += 1
print(i)


n = int(input())
a = list(map(int, input().split()))
mid = sum(a) / len(a)
if mid >= 4.5:
	print(0)
else:
	count = 0
	while mid < 4.5:
		a[a.index(min(a))] = 5
		mid = sum(a) / len(a)
		count += 1
	print(count)


import time
n = int(input())
a = [int(i) for i in input().split()]
start = time.time()
a.sort()
need = 9 * n
s = sum(a) * 2
ans = 0
while s < need:
	s += 10 - 2 * a[ans]
	ans += 1
print(ans)
finish = time.time()


import math
t = input().strip().split(' ')
n = int(t[0])
t = input().strip().split(' ')
scores = [int(e) for e in t]
big = [0, 0, 0, 0, 0, 0]
myscore = 0
for score in scores:
	big[score] += 1
	myscore += score
myneed = int(math.ceil(4.5 * n))
result = 0
for i in range(2, 5):
	if myscore >= myneed:
		break
	local_need = math.ceil((myneed - myscore) / (5 - i))
	if local_need <= big[i]:
		result += local_need
		break
	result += big[i]
	myscore += (5 - i) * big[i]
print(result)


ng = int(input())
g = list(map(int, input().split()))
s = sum(g)
improv = 4.5 * ng - s
sumImprov = 0
c = 0
reverse = sorted(g)
while sumImprov < improv:
	sumImprov += 5 - reverse[c]
	c += 1
print(c)


n = int(input())
arr = list(map(int, input().split()))
total = n * 5
changes = 0
while round(sum(arr) / total, 3) * 5 < 4.5:
	arr.sort()
	arr[0] = 5
	changes += 1
print(changes)


n = int(input())
s = [int(x) for x in input().split()]
s.sort()
ans = 0
t = 4.5 * n
cur_s = sum(s)
for i in s:
	if cur_s < t:
		cur_s += 5 - i
		ans += 1
	if cur_s >= t:
		print(ans)
		exit()


n = int(input())
m = list(map(int, input().split()))
m.sort()
count = 0
for i in range(len(m) + 1):
	if sum(m) / len(m) >= 4.5:
		print(count)
		break
	if len(m) == 1:
		print(1)
		break
	m[i] = 5
	count += 1


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
res = 0
while sum(arr) / len(arr) < 4.5:
	arr[res] = 5
	res += 1
print(res)


N = int(input())
data = [int(i) for i in input().split()]
s = sum(data)
should = 4.5 * N
if N % 2:
	should = int(should) + 1
else:
	should = int(should)
ht = {}
ht[2] = 0
ht[3] = 0
ht[4] = 0
ht[5] = 0
for i in data:
	ht[i] += 1
tochange = should - s
if tochange <= 0:
	print(0)
else:
	cur = 2
	ans = 0
	while True:
		if tochange <= 0:
			break
		elif ht[cur] != 0:
			tochange -= 5 - cur
			ht[cur] -= 1
			ans += 1
		else:
			cur += 1
	print(ans)


n = int(input())
grades = list(map(int, input().split()))
grades.sort()
cur = sum(grades) / len(grades)
i = 0
while cur < 4.5:
	grades[i] = 5
	cur = sum(grades) / len(grades)
	i += 1
print(i)


n = int(input().strip())
a = sorted(list(map(int, input().strip().split())))
r = 0
while True:
	mean = sum(a) / n
	if round(mean) >= 5 or mean == 4.5:
		break
	r += 1
	a[0] = 5
	a.sort()
print(r)


import itertools
n = int(input())
grades = sorted(map(int, input().split()))
total = sum(grades)
remain = (9 * n - 1) // 2 + 1 - total
if remain <= 0:
	answer = 0
else:
	for (i, accum) in enumerate(itertools.accumulate(grades)):
		if 5 * (i + 1) - accum >= remain:
			answer = i + 1
			break
print(answer)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def solve():
	n = int(inp())
	ar = lis()
	aim = 4.5 * n
	ar.sort()
	want = aim - sum(ar)
	s = 0
	c = 0
	for i in range(n):
		if s >= want:
			break
		else:
			s += 5 - ar[i]
			c += 1
	print(c)
solve()


n = int(input())
a = [int(m) * 2 for m in input().split()]
s = sum(a)
a.sort()
ans = 0
for i in a:
	if s >= 9 * n:
		break
	s += 10 - i
	ans += 1
print(ans)


N = int(input())
grade = list(map(int, input().split()))
grade_sum = sum(grade)
grade.sort()
need = N * 4.5 - grade_sum
ans = 0
while 1:
	if need <= 0:
		break
	need -= 5 - grade[ans]
	ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
a = [i * 2 for i in a]
tot = sum(a)
target = 9 * n
a.sort()
cnt = 0
if tot >= target:
	print(0)
	exit(0)
for v in a:
	tot += 10 - v
	cnt += 1
	if tot >= target:
		print(cnt)
		exit(0)


def heapify(arr, n, i):
	largest = i
	l = 2 * i + 1
	r = 2 * i + 2
	if l < n and arr[l] > arr[largest]:
		largest = l
	if r < n and arr[r] > arr[largest]:
		largest = r
	if largest != i:
		(arr[largest], arr[i]) = (arr[i], arr[largest])
		heapify(arr, n, largest)

def sor(arr):
	for i in range(len(arr) // 2 + 1, -1, -1):
		heapify(arr, len(arr), i)
	for i in range(len(arr) - 1, 0, -1):
		(arr[i], arr[0]) = (arr[0], arr[i])
		heapify(arr, i, 0)

def roundoff(n):
	if n - int(n) >= 0.5:
		return int(n) + 1
	return int(n)
n = int(input())
sum = roundoff(4.5 * n)
lab = 0
a = []
for i in input().split():
	lab = lab + int(i)
	a.append(int(i))
sor(a)
count = 0
for i in a:
	if lab > sum - 1:
		break
	(count, lab) = (count + 1, lab + 5 - i)
print(count)


n = int(input())
grade = list(map(int, input().split()))
sum = sum(grade)
dif = n * 4.5 - sum
amount = [grade.count(i) for i in range(2, 5)]
result = 0
for (i, j) in enumerate(amount):
	if j != 0:
		if dif >= j * (3 - i):
			result += j
			dif -= j * (3 - i)
		else:
			result += dif // (3 - i) + (dif % (3 - i) != 0)
			dif -= (dif // (3 - i) + (dif % (3 - i) != 0)) * (3 - i)
	if dif <= 0:
		break
print(int(result))


a = int(input())
l = list(map(int, input().split()))
l.sort()
h = 0

def summa():
	global a
	global l
	global h
	h = 0
	for i in range(len(l)):
		h += l[i]
	h = h / a
summa()
t = 0
while h < 4.5:
	l[t] = 5
	summa()
	t += 1
print(t)


n = int(input())
l = list(map(int, input().split()))
l.sort()
sum1 = 0
count = 0
for i in range(0, n):
	sum1 = sum1 + l[i]
if sum1 / n < 4.5:
	x = 4.5 * n - sum1
	for i in range(0, n):
		count = count + 1
		x = x - (5 - l[i])
		if x <= 0:
			print(count)
			break
else:
	print(0)


n = int(input())
grades = map(int, input().split())
grades = sorted(grades)
labs = 0
avg = sum(grades) / n
while avg < 4.5:
	grades[labs] = 5
	labs += 1
	avg = sum(grades) / n
print(labs)


n = int(input())
a = list(map(int, input().split()))
k = sum(a)
av = k / n
c = 0
if av < 4.5:
	a.sort()
	s = int(n * 4.5) - k
	if n % 2 != 0:
		s += 1
	q = 0
	for i in range(n):
		if q >= s:
			break
		else:
			q += 5 - a[i]
			c += 1
print(c)


import sys
import math
import itertools
import collections

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
n = ii()
a = sorted(li())
i = 0
while sum(a) * 2 < 9 * n:
	if a[i] == 5:
		continue
	else:
		a[i] = 5
		i += 1
print(i)


n = int(input())
a = sorted(map(int, input().split()))
k = 0
while k * 10 + 2 * sum(a[k:]) < 9 * n:
	k += 1
print(k)


n = int(input())
a = sorted(map(int, input().split()))
(s, i) = (sum(a) - n * 4.5, 0)
while 1:
	if s >= 0:
		break
	s += 5 - a[i]
	i += 1
print(i)


import math

def a(k):
	if k % 1 >= 0.5:
		return ceil(k)
	return floor(k)
n = int(input())
num = list(map(int, input().split()))
num.sort()
x = sum(num)
ans = 0
while x / n < 4.5:
	x = x + 5 - num[ans]
	ans += 1
print(ans)


n = int(input())
s = list(map(int, input().strip().split()))
s = sorted(s)
mean = sum(s) / len(s)
l = 0
while mean < 4.5:
	s[l] = 5
	l += 1
	mean = sum(s) / len(s)
print(l)


n = int(input())
labs = [int(a) for a in input().split()]
labs.sort()
redo = 0
while sum(labs) / len(labs) < 4.5:
	labs[redo] = 5
	redo += 1
print(redo)


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	n = inp()
	l = li()
	s = sum(l)
	l.sort()
	ans = 0
	i = 0
	while i < n and round(s / n) != 5:
		if s / n == 4.5:
			break
		s -= l[i]
		s += 5
		ans += 1
		i += 1
	pr(ans)
for _ in range(1):
	solve()


n = int(input())
a = list(map(int, input().split()))
s = sum(a)
k = 0
if s / n >= 4.5:
	print(0)
else:
	while s / n < 4.5:
		a.remove(min(a))
		a.append(5)
		s = sum(a)
		k += 1
	print(k)


n = int(input())
t = list(map(int, input().split()))
k = 0
for i in range(n):
	k += t[i]
	t[i] = t[i] - 5
t.sort()
h = 4.5 * n
i = 0
while k < h:
	k -= t[i]
	i += 1
	if i == n:
		break
print(i)


n = int(input())
m = list(map(int, input().split()))
m.sort()

def c(m):
	a = 0
	for i in range(n):
		a += m[i]
	a /= n
	a += 0.5
	a = int(a)
	return a
b = 0
while c(m) < 5:
	m[b] = 5
	b += 1
print(b)


import math
n = int(input())
l = list(map(int, input().split()))
k = float(sum(l))
o = len(l)
c = 0
while True:
	check = k / o
	p = list(str(check))
	i = int(p[p.index('.') + 1])
	if i >= 5:
		check = float(math.ceil(check))
	elif i < 5:
		check = float(math.floor(check))
	else:
		pass
	if check >= 5:
		break
	k += 1
	c += 1
r = 0
l.sort()
for t in l:
	i = 5 - t
	if c <= 0:
		break
	elif i > 0:
		c -= i
		r += 1
print(r)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = 0
if sum(l) / n >= 4.5:
	print(0)
else:
	for i in range(n):
		l[i] = 5
		if sum(l) / n >= 4.5:
			print(i + 1)
			break


n = int(input())
l = list(map(int, input().split()))
count = 0
minreq = 4.5 * n
req = minreq - sum(l)
while req > 0:
	m = min(l)
	req -= 5 - m
	l.remove(m)
	count += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
num = len(a)
s = 0
for i in range(len(a)):
	s += a[i]
if s >= 4.5 * num:
	print(0)
else:
	a.sort()
	ref = 4.5 * num
	ref -= s
	i = 0
	while i < len(a) and ref > 0:
		ref -= 5 - a[i]
		i += 1
	print(i)


n = int(input())
a = sorted(map(int, input().split()))
sm = 0.0
for i in a:
	sm += i
t = sm / n
if t >= 4.5:
	print(0)
else:
	for i in range(0, n):
		sm -= a[i]
		sm += 5
		t = float(sm) / float(n)
		if t >= 4.5:
			print(i + 1)
			break


import atexit, io, sys
buffer = io.StringIO()
sys.stdout = buffer

@atexit.register
def write():
	sys.__stdout__.write(buffer.getvalue())
from sys import stdin, stdout

def main():
	s_obt = 0

	def myord(num):
		nonlocal s_obt
		s_obt += num
		return num
	s_min = 4.5 * int(stdin.readline())
	cal = (int(x) for x in stdin.readline().split())
	cal = sorted(cal, key=myord)
	nt = 0
	while s_min > s_obt:
		s_obt += 5 - cal[nt]
		nt += 1
	stdout.write(str(nt))
main()


n = int(input())
g = list(map(int, input().split()))
g.sort()
s = sum(g) / n
i = 0
while s < 4.5:
	if g[i] < 5:
		g[i] = 5
	i = i + 1
	s = sum(g) / n
print(i)


from sys import stdout, stdin, setrecursionlimit
from io import BytesIO, IOBase
from collections import *
from itertools import *
from bisect import *
from string import *
from queue import *
from heapq import *
from math import *
from re import *
from os import *

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = read(self._fd, max(fstat(self._fd).st_size, 8192))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

def getStrs():
	return input().split()

def isInt(s):
	return '0' <= s[0] <= '9'

def input():
	return stdin.readline().strip()

def zzz():
	return [int(i) for i in input().split()]

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
n = getInt()
arr = szzz()
i = 0
while sum(arr) / n + 0.5 < 5:
	arr[i] = 5
	i += 1
print(i)


n = int(input())
grades = [int(x) for x in input().split()]
grades.sort()
req = 4.5 * n - sum(grades)
ans = 0
for i in grades:
	if req <= 0:
		break
	req -= 5 - i
	ans += 1
print(ans)


import math
t = int(input())
a = list(map(int, input().split()))[:t]
a.sort()
x = sum(a) / t
c = 0
i = 0
while x < 4.5:
	if a[i] < 5:
		a[i] = 5
	i = i + 1
	c = c + 1
	x = sum(a) / t
print(c)


n = int(input())
l = list(map(int, input().split()))
l.sort()

def avg(arr):
	return sum(arr) / n
ans = 0
while avg(l) < 4.5:
	l[ans] = 5
	ans += 1
print(ans)


n = int(input())
x = map(int, input().split())
x = sorted(x)
a = sum(x)
c = 0
flag = 0
for i in x:
	if a / n >= 4.5:
		flag = 1
		print(c)
		break
	a += 5 - i
	c += 1
if flag == 0:
	print(c)


n = int(input())
s = sorted([int(x) for x in input().split()])
i = 0
while sum(s) < 4.5 * n:
	s[i] = 5
	i += 1
print(i)


n = int(input())

def mean(grades):
	return sum(grades) / n
grades = list(map(int, input().strip().split()))
grade = mean(grades)
grades = sorted(grades)
count = 0
i = 0
while mean(grades) < 4.5:
	grades[i] = 5
	i += 1
	count += 1
print(count)


def ans(f, n):
	return f * 10 >= n * 45
l1 = []
f = 0
t = int(input())
l = list(map(int, input().split()))
f = sum(l)
l.sort()
x = 0
while not ans(f, t):
	f += 5 - l[x]
	x += 1
print(x)


n = int(input())
l = input().split(' ')
s = 0
l = list(map(int, l))
l.sort()
for i in l:
	s = s + i
s = s / n
s = s + 1e-06
s = round(s)
nb = 0
while s < 5:
	l[0] = 5
	l.sort()
	s = 0
	for i in l:
		s = s + i
	s = s / n
	s = s + 1e-06
	s = round(s)
	nb = nb + 1
print(nb)


k = 0
n = int(input())
s = list(map(int, input().split()))
while sum(s) / n < 4.5:
	a = min(s)
	b = s.index(a)
	s.pop(b)
	s += [5]
	k += 1
print(k)


import math
n = int(input())
s = sorted(list(map(int, input().split())))
sm = sum(s)
count = 0
i = 0
eps = 10 ** (-10)
while round(sm / n + eps) != 5:
	count += 1
	sm = sm - s[i] + 5
	i += 1
print(count)


n = int(input())
x = [int(x) for x in input().split()]
x.sort()
i = 0
while sum(x) < 4.5 * n:
	x[i] = 5 - x[i] + x[i]
	i += 1
print(i)


n = int(input())
s = list(map(int, input().split()))
s.sort()
sm = sum(s)
c = float(sum(s) / n)
cnt = 0
j = 0
while c < 4.5:
	sm = sm - s[j]
	s[j] = 5
	cnt += 1
	sm = sm + s[j]
	c = float(sm / n)
	j += 1
print(cnt)


n = int(input())
A = sorted(list(map(int, input().split())))
s = sum(A)
s += n / 2
N = 5 * n
x = 0
while s < N:
	s = s + 5 - A[x]
	x += 1
print(x)


n = int(input())
arr = list(map(int, input().strip().split(' ')))
arr.sort()
s = sum(arr)
if s >= 4.5 * n:
	print(0)
else:
	cnt = 0
	for i in range(n):
		cnt += 1
		s = s - arr[i] + 5
		if s >= 4.5 * n:
			break
	print(cnt)


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

def main():
	n = int(input())
	nums = rli()
	nums.sort()
	ans = sum(nums)
	if ans / float(n) >= 4.5:
		print(0)
		return
	for i in range(len(nums)):
		ans += 5 - nums[i]
		if ans / float(n) >= 4.5:
			print(i + 1)
			return
main()


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def primeFactorsCount(n):
	cnt = 0
	while n % 2 == 0:
		cnt += 1
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			cnt += 1
			n = n // i
	if n > 2:
		cnt += 1
	return cnt

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

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s
n = int(input())
l = sorted(list(map(int, input().split())))
s = sum(l)
ans = 0
req = 4.5 * n
i = 0
while s < req:
	s += 5 - l[i]
	ans += 1
	i += 1
print(ans)


from sys import *

def main():
	n = int(stdin.readline())
	target = 4.5 * n
	currentTotal = 0
	minimumRetakes = 0
	listOfScores = [int(x) for x in stdin.readline().split()]
	for x in listOfScores:
		currentTotal += x
	listOfScores.sort()
	while currentTotal < target:
		currentTotal += 5 - listOfScores[minimumRetakes]
		minimumRetakes += 1
	print(minimumRetakes)
main()


n = int(input())
l = list(map(int, input().split()))
fl4 = 0
fl2 = 0
fl3 = 0
s = 0
c = 0
for i in range(n):
	if l[i] == 2:
		fl2 += 1
	elif l[i] == 3:
		fl3 += 1
	elif l[i] == 4:
		fl4 += 1
	s += l[i]
while fl2 != 0 or fl3 != 0 or fl4 != 0:
	if s / n >= 4.5:
		print(0)
		quit()
	if fl2 != 0:
		s += 5 - 2
		c += 1
		if s / n >= 4.5:
			print(c)
			quit()
		fl2 -= 1
		continue
	if fl3 != 0:
		s += 5 - 3
		c += 1
		if s / n >= 4.5:
			print(c)
			quit()
		fl3 -= 1
		continue
	if fl4 != 0:
		s += 5 - 4
		c += 1
		if s / n >= 4.5:
			print(c)
			quit()
		fl4 -= 1
		continue
if c == 0:
	print(c)


n = int(input())
current_marks = list(map(int, input().split(' ')))
current_sum = sum(current_marks)
target_sum = n * 4.5
required_marks = target_sum - current_sum
counter = 0
current_marks.sort()
for i in current_marks:
	if required_marks <= 0:
		break
	else:
		counter += 1
		required_marks -= 5 - i
print(counter)


from math import ceil
n = int(input())
arr = sorted(list(map(int, input().split())))
tot = sum(arr)
req = 4.5 * n
idx = 0
while tot < req:
	tot -= arr[idx]
	tot += 5
	idx += 1
print(idx)


n = int(input())
a = list(map(int, input().split()))
rec = []
for i in range(n):
	if a[i] != 5:
		rec.append((a[i], i))
rec = sorted(rec)
j = 0
s = sum(a)
while s < 4.5 * n:
	s += 5 - a[rec[j][1]]
	j += 1
print(j)


n = int(input())
a = sorted(map(int, input().split()))
t = (9 * n + 1) // 2
s = 0
for x in a:
	s += x
if s >= t:
	print(0)
else:
	a.sort()
	for i in range(n):
		s += 5 - a[i]
		if s >= t:
			print(i + 1)
			break


def main():
	n = int(input())

	def ceil(x):
		if x % 1 == 0:
			return int(x)
		return int(x + 1)
	a = ceil(n * 4.5)
	scores = sorted(list(map(int, input().split())))
	s = sum(scores)
	c = 0
	while s < a:
		s += 5 - scores[c]
		c += 1
	print(c)
	return 0
main()


n = int(input())
a = [float(x) for x in input().split()]
ans = 0
while sum(a) / n < 4.5:
	a.remove(min(a))
	a.append(5)
	ans += 1
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
ans = 0
while sum(arr) / n < 4.5:
	arr[ans] = 5
	ans += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
a.sort()
goal = 9 * n
cs = sum(a) * 2
ans = 0
for v in a:
	if cs >= goal:
		break
	cs += 10 - 2 * v
	ans += 1
print(ans)


n = int(input())
ai = list(map(int, input().split()))
ai.sort()
summ = sum(ai)
if summ / n >= 4.5:
	print(0)
else:
	for i in range(n):
		summ += 5 - ai[i]
		if summ / n >= 4.5:
			print(i + 1)
			break


from math import ceil
n = int(input())
l = [int(x) for x in input().split()]
l.sort()
summ = 4.5 * n
if ceil(summ) <= sum(l):
	print('0')
	exit(0)
diff = ceil(summ) - sum(l)
ans = 0
for ele in l:
	diff -= 5 - ele
	ans += 1
	if diff <= 0:
		break
print(ans)


num = int(input())
grades = sorted(list(map(int, input().split())))
counter = 0
if sum(grades) / num < 4.5:
	while sum(grades) / num < 4.5:
		if grades[counter] != 5:
			grades[counter] = 5
			counter += 1
		else:
			counter = 0
	print(counter)
else:
	print(counter)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
n = int(input())
g = list(map(int, input().split()))
if sum(g) / n >= 4.5:
	print(0)
else:
	g.sort()
	netsum = sum(g)
	ans = 0
	for i in range(n):
		netsum -= g[i]
		netsum += 5
		ans += 1
		if netsum / n >= 4.5:
			break
	print(ans)


n = int(input())
arr = [int(i) for i in input().split()]
arr.sort()
sum = sum(arr)
pos = 0
while sum / n < 4.5:
	sum += 5 - arr[pos]
	pos += 1
print(pos)


n = int(input())
l = list(map(int, input().split()))
l.sort()
s = sum(l)
c = 0
while s / n < 4.5:
	c += 1
	l[0] = 5
	l.sort()
	s = sum(l)
print(c)


import math
getInputList = lambda : list(input().split())
getInputIntList = lambda : list(map(int, input().split()))
n = int(input())
arr = getInputIntList()
arr.sort()
ans = 0
s = sum(arr)
for i in arr:
	if round(round(s / n, 2) + 0.01) == 5:
		print(ans)
		break
	s += 5 - i
	ans += 1
else:
	print(ans)


__author__ = 'Esfandiar'
n = int(input())
a = sorted(list(map(int, input().split())))
su = sum(a)
res = 0
while su / n < 4.5:
	su += 5 - a[res]
	res += 1
print(res)


n = int(input())
data = list(map(int, input().split()))
bads = 0
mass = []
s = 0
for el in data:
	if el < 5:
		bads += 1
		mass.append(el)
		s += el
ans = 0
mass.sort()
mass = mass[::-1]
for i in range(bads + 1):
	if ((n - bads + i) * 5 + s) * 2 >= 9 * n:
		ans = i
		break
	else:
		s -= mass.pop(-1)
print(ans)


n = int(input())
ar = list(map(int, input().split()))
av = sum(ar) / n
s = sum(ar)
if av >= 4.5:
	print(0)
else:
	ar.sort()
	count = 0
	for i in ar:
		s -= i
		s += 5
		av = s / n
		count += 1
		if av >= 4.5:
			break
	print(count)


import sys
n = int(sys.stdin.readline())
notes = list(map(int, sys.stdin.readline().split()))
notes.sort()
somme = 0
for a in notes:
	somme += a
(i, t) = (0, 0)
while somme / n < 4.5:
	somme += 5 - notes[i]
	notes[i] = 5
	t += 1
	i += 1
print(t)


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
x = s / n
count = 0
while x < 4.5:
	a = l.index(min(l))
	l[a] = 5
	count += 1
	s = sum(l)
	x = s / n
print(count)


n = input()
v = [int(x) for x in input().split(' ')]
n = len(v)
target = float(n * 4.5)
cur_sum = sum(v)
if cur_sum > target:
	print(0)
else:
	i = 0
	v.sort()
	while cur_sum < target:
		temp = 5 - v[i]
		cur_sum = cur_sum + temp
		i = i + 1
	print(i)


n = int(input())
marks = list(map(int, input().split()))
marks.sort()
sr_znach = sum(marks) / n
count = 0
i = 0
while sr_znach < 4.5:
	sr_znach = sum(marks) / n
	if sr_znach >= 4.5:
		break
	count += 1
	marks[i] = 5
	i += 1
print(count)


n = int(input())
a = [int(i) for i in input().split()]
a.sort()
for i in range(n):
	if 2 * sum(a) >= 9 * n:
		print(i)
		break
	a[i] = 5
else:
	print(n)


from math import ceil
n = int(input())
arr = [int(i) for i in input().split()]
sum = 0
for i in range(n):
	sum += arr[i]
avg = sum / n
if avg - int(avg) >= 0.5:
	intavg = int(avg) + 1
else:
	intavg = int(avg)
if intavg == 5:
	print(0)
else:
	arr.sort()
	c = 0
	req = ceil(4.5 * n)
	i = 0
	while sum < req:
		sum += 5 - arr[i]
		i += 1
		c += 1
	print(c)


def result(a):
	b = sorted(a)
	summa = sum(a)
	m = len(a)
	count = 0
	while not summa * 10 >= m * 45:
		summa += 5 - b[count]
		count += 1
	return count
lt = int(input())
lst = [int(i) for i in input().split()]
print(result(lst))


import math
n = int(input())
a = [int(i) for i in input().split()]
avr = 0
a.sort()
for i in a:
	avr += i
avr = avr / n
if avr - 4.5 >= 0:
	print(0)
else:
	num = 4.5 - avr
	num = num * n
	if abs(int(num) - num) > 1e-07:
		num = math.ceil(num)
	else:
		num = int(num)
	cnt = 0
	for i in a:
		num += i - 5
		cnt += 1
		if num <= 0:
			break
	print(cnt)


n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
k = 0
x = 0
for j in range(n):
	x = x + a[j]
r = 0
while x < 4.5 * n:
	x = x + 5 - a[r]
	a[r] = 5
	r = r + 1
	k = k + 1
print(k)


(n, a) = (int(input()), list(sorted(map(int, input().split()))))
(good_sum, summ) = (4.5 * n, sum(a))
res = 0
for i in range(n):
	if summ >= good_sum:
		break
	summ += 5 - a[i]
	res += 1
print(res)


from math import ceil
n = int(input())
marks = list(map(int, input().split()))
marks.sort()
reqMarks = n * 4.5
curMarks = sum(marks)
i = 0
while curMarks < reqMarks:
	curMarks += 5 - marks[i]
	i += 1
print(i)


R = lambda : map(int, input().split())
(n,) = R()
arr = sorted(R())
val_sum = sum(arr)
count = 0
if val_sum / n >= 4.5:
	print(count)
else:
	for i in range(n):
		if val_sum / n >= 4.5:
			break
		arr[i] = 5
		val_sum = sum(arr)
		count += 1
	print(count)


n = int(input())
arr = sorted((int(x) for x in input().split()))
i = 0
while i < len(arr):
	if sum(arr) / n >= 4.5:
		break
	arr[i] = 5
	i += 1
print(i)


import math
n = int(input())
a = list(map(int, input().split()))
tot = sum(a)
a.sort()
ans = math.ceil(4.5 * n)
c = 0
if tot >= ans:
	print('0')
else:
	for i in a:
		if i < 5:
			c += 1
			tot += 5 - i
			if tot >= ans:
				break
	print(c)


def avg_check(lst, n):
	if sum(lst) / n >= 4.5:
		return True
	return False
n = int(input())
arr = list(map(int, input().split()))
if avg_check(arr, n):
	print(0)
else:
	arr.sort()
	count = 0
	while True:
		arr[0] = 5
		count += 1
		arr.sort()
		if avg_check(arr, n):
			break
	print(count)


n = int(input())
marks = list(map(int, input().split()))
marks.sort()
count = 0
i = 0
avg = sum(marks) / n
while avg < 4.5:
	marks[i] = 5
	i += 1
	count += 1
	avg = sum(marks) / n
print(count)


def go():
	n = int(input())
	a = sorted([int(i) for i in input().split(' ')])
	s = sum(a)
	if s / n >= 4.5:
		return 0
	c = 0
	for i in range(n):
		s -= a[i]
		a[i] = 5
		s += 5
		c += 1
		if s / n >= 4.5:
			return c
print(go())


A = int(input())
B = [int(i) for i in input().split()]
B.sort()
ch = 0
while sum(B) / A < 4.5:
	B[0] = 5
	B.sort()
	ch += 1
print(ch)


import sys
input = sys.stdin.readline

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

def float_compare(a, b):
	if abs(a - b) < float(1e-09):
		return True
	else:
		return False

def sub_mod(x, mod):
	x = x % mod
	if x < 0:
		x += mod
	return x

def divisor(n):
	i = 1
	dv = []
	while i * i <= n:
		if n % i == 0:
			dv.append(i)
			if i * i != n:
				dv.append(n // i)
		i += 1
	return dv

def rnd(a, b):
	x = a / b
	y = a // b
	if x - y >= 0.5:
		return y + 1
	else:
		return y
n = int(input())
l = list_input()
m_ans = 0
while rnd(sum(l), n) != 5:
	l[l.index(min(l))] = 5
	m_ans += 1
print(m_ans)


n = int(input())
sums = 0.0
k = 0
arr = list((int(x) for x in input().split()))
for i in range(n):
	sums = sums + arr[i]
arr.sort()
while 1:
	if sums / n >= 4.5:
		print(k)
		exit(0)
	else:
		sums = sums + 5 - arr[k]
		k += 1


n = int(input())
inp = list(map(int, input().split()))
k = sum(inp) / len(inp)
if k >= 4.4999:
	print(0)
else:
	inp.sort()
	count = 0
	for i in range(0, len(inp)):
		k = k + (5 - inp[i]) / len(inp)
		count = count + 1
		if k >= 4.4999:
			break
	print(count)


n = int(input())
grades = input()
grades = grades.split(' ')
count = [0, 0, 0, 0]
tot = 0
for g in grades:
	tot += int(g)
	count[int(g) - 2] += 1
final = float(tot) / n
ans = 0
if final >= 4.5:
	a = 0
else:
	diff = 4.5 - final
	if round(diff * n, 2) > int(diff * n):
		need = int(diff * n) + 1
	else:
		need = int(diff * n)
	twos = count[0] * 3
	if twos >= need:
		if need % 3 == 0:
			ans += int(need / 3)
		else:
			ans += int(need / 3) + 1
	else:
		need -= twos
		ans += count[0]
		threes = count[1] * 2
		if threes >= need:
			if need % 2 == 0:
				ans += int(need / 2)
			else:
				ans += int(need / 2) + 1
		else:
			need -= threes
			ans += count[1]
			ans += need
print(ans)


a = int(input())
t = list(map(int, input().split()))
t.sort()
if sum(t) / a >= 4.5:
	print(0)
else:
	for k in range(a):
		t[k] = 5
		if sum(t) / a >= 4.5:
			print(k + 1)
			break


n = int(input())
l = sorted(map(int, input().split()), reverse=True)
t = n * 5 - sum(l) - n // 2
while t > 0:
	t -= 5 - l.pop()
print(n - len(l))


n = int(input())
data = list(map(int, input().split()))
data.sort()
req = 4.5 * n
ans = 0
while sum(data) < req:
	data = data[1:] + [5]
	ans += 1
print(ans)


n = int(input())
l = [int(x) for x in input().split()]
l.sort()
avg = sum(l) / n
z = 0
if avg >= 4.5:
	print('0')
else:
	for i in range(len(l)):
		l[i] = l[i] + (5 - l[i])
		avg = sum(l) / n
		z += 1
		if avg >= 4.5:
			print(z)
			break
		else:
			continue


n = int(input())
a = list(map(int, input().split()))
k = 0
d = 0
if sum(a) / n >= 4.5:
	print(0)
else:
	s = sum(a)
	m = 5
	while sum(a) / n < 4.5:
		for i in range(n):
			if a[i] < m:
				m = a[i]
				k = i
		a[k] = 5
		m = 5
		d += 1
	print(d)


n = int(input())
l = list(map(int, input().split()))
l.sort()
if sum(l) / n >= 4.5:
	print(0)
else:
	c = 0
	i = 1
	while 1:
		if (sum(l[i:]) + 5 * i) / n >= 4.5:
			c += 1
			break
		i += 1
	print(i)


bespoleznoe_chislo = input()
a = [int(s) for s in input().split()]
s = sum(a) / len(a)
i = 0
while s < 4.5:
	a[a.index(min(a))] = 5
	s = sum(a) / len(a)
	i += 1
print(i)


n = int(input())
a = list(map(int, input().split()))
sm = sum(a)
req = 4.5 * n
a.sort()
idx = 0
while sm < req and idx < n:
	a[idx] = 5
	idx += 1
	sm = sum(a)
print(idx)


n = int(input())
A = list(map(int, input().strip().split()))
s = sum(A)
if s > int(4.5 * n):
	print(0)
else:
	A.sort()
	i = 0
	while s < 4.5 * n:
		s += 5 - A[i]
		i += 1
	print(i)


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
n = int(input())
a = list(map(int, sys.stdin.readline().split(' ')))
reach = math.ceil(4.5 * n)
s = sum(a)
a.sort()
ans = reach - s
count = 0
for aa in a:
	if ans <= 0:
		break
	ans -= 5 - aa
	count += 1
print(count)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


n = int(input())
a = list(map(int, input().split()))
less = 0
res = 0
for change in range(2, 6):
	cnt = 0
	cur_sum = 0
	for i in range(n):
		cur_sum += a[i]
	for i in range(n):
		if a[i] == change:
			cnt += 1
	least_want = int(4.5 * n + 0.9)
	if least_want <= cur_sum:
		print(res)
		break
	need = int((least_want - cur_sum + (5 - change) - 1) / (5 - change))
	if need <= cnt:
		print(need + res)
		break
	for i in range(n):
		if a[i] == change:
			a[i] = 5
	res += cnt


e = 10 ** (-8)
c = float(input())
grades = sorted(list(map(int, input().split())))
total = sum(grades)
avg = total / c
inc_per_point = 1 / c
changes = 0
while avg < 4.5 - e:
	g = grades.pop(0)
	improvement = 5 - g
	avg += improvement * inc_per_point
	changes += 1
print(changes)


sumofestimates = int(input())
estimates = list(map(int, input().split()))
answer = 0
estimates.sort()

def checker():
	counter = 0
	for k in estimates:
		counter += k
	counter /= sumofestimates
	return counter
r = checker()
while r < 4.5:
	l = estimates.pop(0)
	estimates.append(5)
	r = checker()
	answer += 1
print(answer)


import math
n = int(input())
a = list(map(int, input().split()))
sum1 = sum(a) / n
temp = str(sum1).split('.')
if int(temp[1][0]) < 5:
	ans = math.floor(sum1)
else:
	ans = math.ceil(sum1)
if ans == 5:
	print(0)
else:
	count = 0
	temp2 = sum(a)
	while ans != 5:
		temp2 = temp2 + 5 - min(a)
		a.remove(min(a))
		count = count + 1
		sum1 = temp2 / n
		temp = str(sum1).split('.')
		if int(temp[1][0]) < 5:
			ans = math.floor(sum1)
		else:
			ans = math.ceil(sum1)
		if ans == 5:
			print(count)
			exit()


n = int(input())
a = list(map(int, input().split()))
b = a.count(2)
c = a.count(3)
d = a.count(4)
temp = sum(a)
count = 0
while 1:
	if temp / n >= 4.5:
		break
	elif b > 0:
		b -= 1
		temp += 3
		count += 1
	elif c > 0:
		c -= 1
		temp += 2
		count += 1
	elif d > 0:
		d -= 1
		temp += 1
		count += 1
print(count)


from decimal import Decimal

def checker(m):
	cur_sum = marks_sum
	i = 0
	while m > 0 and i < n:
		if marks[i] != 5:
			cur_sum += 5 - marks[i]
			m -= 1
		i += 1
	cur_avg = Decimal(cur_sum) / Decimal(n)
	if cur_avg >= 4.5:
		return True
	else:
		return False
n = int(input())
marks = list(map(int, input().split()))
marks.sort()
marks_sum = sum(marks)
l = -1
r = n
while l + 1 < r:
	m = (l + r) // 2
	if checker(m):
		r = m
	else:
		l = m
print(r)


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
reqsum = 4.5 * n
act_sum = 0
for i in arr:
	act_sum += i
count = 0
i = 0
while act_sum < reqsum:
	if arr[i] < 5:
		act_sum += 5 - arr[i]
		count += 1
	i += 1
print(count)


n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
count = 0
while sum(a) / n < 4.5:
	a.pop(0)
	a.append(5)
	count += 1
print(count)


import sys

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

def iinput():
	return int(input())

def minput():
	return map(int, input().split())

def listinput():
	return list(map(int, input().split()))
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
summ = sum(arr)
k = 0
while summ / n < 4.5:
	summ += 5 - arr[k]
	k += 1
print(k)


n = int(input().strip())
ais = list(map(int, input().strip().split()))
ais.sort()
cnt = 0
s = sum(ais)
thrs = -(-9 * n // 2)
while s < thrs:
	s += 5 - ais[cnt]
	cnt += 1
print(cnt)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	n = I()
	a = sorted(LI())
	s = sum(a)
	t = n * 4.5
	for i in range(n):
		if s >= t:
			return i
		s += 5 - a[i]
	return n
print(main())


n = int(input())
arr = list(map(int, input().strip().split(' ')))
x = 4.5 * n - sum(arr)
if x <= 0:
	print(0)
else:
	arr.sort()
	i = 0
	cnt = 0
	while x > 0:
		x -= 5 - arr[i]
		if arr[i] != 5:
			cnt += 1
		i += 1
		if i == n:
			break
	print(cnt)


a = int(input())
b = list(map(int, input().split()))
c = 0
b.sort()
if int(round(sum(b) / a + 1e-05)) == 5:
	print(0)
else:
	for i in range(a):
		if b[i] < 5:
			b[i] = b[i] + (5 - b[i])
			c += 1
		if int(round(sum(b) / a + 1e-05)) == 5:
			print(c)
			exit()


n = int(input())
l = list(map(int, input().split()))
s = sum(l)
avg = s / n
if avg >= 4.5:
	print(0)
else:
	req = s - avg
	l.sort()
	i = 0
	while True:
		dif = 5 - l[i]
		s = s + dif
		avg = s / n
		if avg >= 4.5:
			print(i + 1)
			break
		i += 1


n = int(input())
p = [int(x) for x in input().split()]
if sum(p) >= n * 9 / 2:
	print(0)
else:
	s = n * (9 / 2) - sum(p)
	for i in range(0, n):
		p[i] = 5 - p[i]
	p = sorted(p)
	t = 0
	y = 0
	for i in range(0, n):
		y += p[n - 1 - i]
		t += 1
		if y >= s:
			print(t)
			break


n = int(input())
a = list(map(int, input().split()))
a.sort()
if n == 1 and a[0] != 5:
	print(1)
elif sum(a) < n * 5 / 1.1 and sum(a) / n < 4.5:
	req = n * 5 / 1.1 - sum(a)
	req1 = req / 5
	if req1 > req // 5 and req1 - req // 5 > 0.11:
		req1 = req // 5 + 1
	for i in range(int(req1)):
		a[i] = 5
	while sum(a) / n < 4.5:
		i += 1
		a[i] = 5
	print(i + 1)
else:
	print(0)


import sys

def read_input():
	count = int(sys.stdin.readline())
	grades = [int(n) for n in sys.stdin.readline().split()]
	return (count, grades)
(count, grades) = read_input()
pro_rated = [grade / count for grade in sorted(grades)]
average = sum(pro_rated)
if average >= 4.5:
	print(0)
else:
	(labs, contribution) = (0, 5 / count)
	while pro_rated and average < 4.49999999:
		pro_rated_grade = pro_rated.pop(0)
		delta = contribution - pro_rated_grade
		average += delta
		labs += 1
	print(labs)


n = int(input())
l = list(map(int, input().split()))
t = sum(l)
k = t / n
l = sorted(l)
(c, p) = (0, 0)
if k >= 4.5:
	print('0')
else:
	for i in l:
		t += 5 - i
		c += 1
		if t / n >= 4.5:
			print(c)
			break


n = int(input())

def r(x):
	if x - int(x) >= 0.5:
		return int(x) + 1
	else:
		return int(x)
arr = list(map(int, input().split(' ')))
arr = sorted(arr)
a = r(sum(arr) / n)
if a == 5:
	print(0)
else:
	c = 0
	for i in range(n):
		arr[i] = 5
		c += 1
		a = r(sum(arr) / n)
		if a == 5:
			print(c)
			break


n = int(input())
l = list(map(int, input().split()))
l.sort()
target = (n * 9 + 1) // 2
o = 0
while sum(l) < target:
	l[0] = 5
	l.sort()
	o += 1
print(o)


n = int(input())
a = sorted(list((int(x) for x in input().split())))
cnt = 0
total = sum(a)
if total / n >= 4.5:
	print(0)
else:
	while 1:
		a[0] = 5
		total = sum(a)
		cnt += 1
		if total / n >= 4.5:
			print(cnt)
			break
		a = sorted(a)


import math
n = int(input())
a = list(map(int, input().split()))
g = math.ceil(4.5 * n) - sum(a)
a.sort()
sum = 0
i = 0
while sum < g:
	sum += 5 - a[i]
	i += 1
print(i)


import math

def rou(x):
	if x - math.trunc(x) >= 0.5:
		return math.ceil(x)
	return math.trunc(x)
n = int(input())
a = list(map(int, input().split()))
a.sort()
s = sum(a)
m = s / n
if rou(m) != 5:
	for i in range(n):
		s += 5 - a[i]
		m = s / n
		if rou(m) == 5:
			print(i + 1)
			break
else:
	print(0)


def change_for_good():
	for i in range(n):
		if inputs[i] == min(inputs):
			break
	inputs[i] = 5
n = int(input())
inputs = [int(x) for x in input().split()]
current_avg = sum(inputs) / n
count = 0
while current_avg < 4.5:
	change_for_good()
	current_avg = sum(inputs) / n
	count += 1
print(count)


n = int(input())
tab = sorted([int(x) for x in input().split()])
s = sum(tab)
result = 0
for i in range(n):
	if 2 * s >= 9 * n:
		break
	result += 1
	s -= tab[i]
	s += 5
print(result)


n = int(input())
a = list(map(int, input().split()))
a.sort()
avg = sum(a) / n
count = 0
i = 0
while avg < 4.5 and i < n:
	if a[i] == 5:
		i += 1
	else:
		count += 1
		a[i] = 5
		avg = sum(a) / n
		i += 1
print(count)


n = int(input())
grades = [int(x) for x in input().split()]
grades = sorted(grades)
curr_sum = sum(grades)
replaces_nr = 0
for grade in grades:
	if curr_sum / n >= 4.5:
		break
	else:
		replaces_nr += 1
		curr_sum += 5 - grade
print(replaces_nr)


n = int(input())
lis = sorted(map(int, input().split()))
s = sum(lis)
c = 0
if s / n >= 4.5:
	print('0')
else:
	for i in range(n):
		s += 5 - lis[i]
		c += 1
		if s / n >= 4.5:
			print(c)
			break


n = int(input())
arr = list(map(int, input().split()))
required = n * 4.5 - sum(arr)
arr = sorted(arr)
i = 0
while i < n and required > 0:
	required -= 5 - arr[i]
	i += 1
print(i)


n = int(input())
a = list(map(int, input().split()))
a.sort()
t = 0
if sum(a) / n < 4.5:
	for i in range(n):
		a[i] = 5
		t += 1
		y = sum(a) / n
		if y >= 4.5:
			break
print(t)


n = int(input())
L = list(map(int, input().split()))
L = sorted(L)
s = sum(L)
c = 0
p = s / n
if p >= 4.5:
	print(0)
else:
	for i in range(n):
		s = s - L[i] + 5
		c += 1
		if s / n >= 4.5:
			print(c)
			break


n = int(input())
arr = list(map(int, input().split()))
arr.sort()
avg = sum(arr) / n
count = 0
while avg < 4.49999999:
	avg += (5 - arr[count]) / n
	count += 1
print(count)


n = int(input())
s = list(map(int, input().split()))
minprice = 4.5 * n
price = 0
for i in s:
	price += i
c = 0
while price < minprice:
	c += 1
	ind = s.index(min(s))
	price += 5 - s[ind]
	s[ind] = 5
print(c)


import math
n = int(input())
a = list(map(int, input().split()))
r = sum(a) / n
if r >= 4.5:
	print(0)
else:
	y = 4.5 * n - sum(a)
	y = int(math.ceil(y))
	z = sum(a) + y
	c = 0
	a.sort()
	for j in range(n):
		if sum(a) < z:
			k = 5 - a[j]
			a[j] = a[j] + k
			c = c + 1
	print(c)


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import sys

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a // gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 1
	right = x
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)

def nCr(n, r):
	return fact(n) // (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a):
	print('? {}'.format(a), flush=True)
	n = lint()
	return n

def dfs(i, p):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	if n > 2:
		l.append(n)
	return l

def fun(a, b):
	q = a / b
	if q % 1 < 0.5:
		return int(q)
	else:
		return int(q) + 1
t = 1
for _ in range(t):
	n = I()
	s = lint()
	s.sort()
	tmp = sum(s)
	i = 0
	while i < n and fun(tmp, n) < 5:
		if s[i] == 5:
			break
		tmp += 5 - s[i]
		i += 1
	if fun(tmp, n) != 5:
		print(-1)
	else:
		print(i)


import math

def mergeSort(lst):
	if len(lst) <= 1:
		return lst
	mid = math.floor(len(lst) / 2)
	left = mergeSort(lst[0:mid])
	right = mergeSort(lst[mid:])
	return merge(left, right)

def merge(arr1, arr2):
	i = 0
	j = 0
	lst = []
	while i < len(arr1) and j < len(arr2):
		if arr1[i] < arr2[j]:
			lst.append(arr1[i])
			i += 1
		else:
			lst.append(arr2[j])
			j += 1
	while i < len(arr1):
		lst.append(arr1[i])
		i += 1
	while j < len(arr2):
		lst.append(arr2[j])
		j += 1
	return lst
num = int(input())
lst = list(map(int, input().split()))
sum = 0
for i in lst:
	sum += i
avg = sum / num
if avg >= 4.5:
	print(0)
else:
	count = 0
	lst = mergeSort(lst)
	i = 0
	while i < len(lst):
		constant = 5 - lst[i]
		lst[i] += constant
		sum += constant
		count += 1
		if sum / num >= 4.5:
			print(count)
			break
		i += 1


n = int(input())
mas = list(map(int, input().split()))
mas.sort()
count = 0
while round(sum(mas) / n + 0.0001) < 5:
	mas[count] = 5
	count += 1
print(count)