题目描述
Problem Description
In recent years, the country of wolves has abolished the 1 yen coin, making the 5 yen coin the smallest denomination, and all currency denominations are now multiples of 5. However, the prices of goods still exist that are not multiples of 5.
Snuke, who is visiting the country of wolves, decided to buy all N items in a certain store. The price of the i-th item is p_i yen.
Since there are no 1 yen coins in this country, when you take some items to the register, if the remainder v of the total price of the items taken divided by 5 is 1 or 2, the total price is reduced by 1 yen or 2 yen respectively. If v is 3 or 4, the total price is increased by 2 yen or 1 yen respectively. If v is 0, the total price remains unchanged.
However, Snuke noticed that dividing the N items into several trips to the register could potentially change the total amount paid depending on the method used. Snuke wants to save as much as possible, so he wants to minimize the total amount paid for all N items by taking them to the register in an appropriate manner. However, since taking items to the register multiple times is too tiring, he also wants to minimize the number of trips to the register among those that minimize the total amount paid.
Find the minimum total amount Snuke has to pay and the minimum number of trips to the register among those that minimize the total amount paid.
Input Format
The input is given from the standard input in the following format:
$ N $ $ p_1 $ : $ p_N $
Output Format
Output the minimum total amount Snuke has to pay and the minimum number of trips to the register among those that minimize the total amount paid, separated by a space.
Sample Input and Output
Sample Input #1
6
1
1
2
1
2
1
Sample Output #1
0 4
Sample Input #2
5
968
127
125
966
861
Sample Output #2
3045 1
Notes/Hints
Constraints
- $1\ \leq\ N\ \leq\ 10^6$
- $1\ \leq\ p_i\ \leq\ 1000$
- All values given in the input are integers
Sample Explanation 1
- Taking the 1st and 2nd items to the register results in a 2 yen discount, making it 0 yen.
- Taking the 4th and 6th items to the register results in a 2 yen discount, making it 0 yen.
- Taking the 3rd item to the register results in a 2 yen discount, making it 0 yen.
- Taking the 5th item to the register results in a 2 yen discount, making it 0 yen.
Thus, it can be achieved by paying a total of 0 yen with 4 trips to the register.
Sample Explanation 2
It is optimal to take all items to the register at once.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分