Codeforces Round 491 (Div. 2)
B
Getting an A
Codeforces
900
原题
← AC →
翻译中…

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$.

翻译中…

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$.

翻译中…

样例

Input #1
3
4 4 4
Output #1
2
InputCopy OutputCopy
Input #2
4
5 4 5 5
Output #2
0
InputCopy OutputCopy
Input #3
4
5 3 3 5
Output #3
1
InputCopy OutputCopy
题目信息
题号
991B
时间限制
1 s
内存限制
256 MB
标签
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。