题目描述
Background
Another year has passed. During the Spring Festival, Xiao Z can relax and enjoy himself, so he and his friends play a game called "Bullfight" (斗牛).
The rules of the game are as follows:
Given 5 cards, each ranging from 1 to 10. You need to select three of these cards whose sum is a multiple of 10. The unit digit of the sum of the remaining two cards is your final score. Specifically, if the sum of these two cards is a multiple of 10, your score is 10, also known as "Bull Blasting." If you cannot form a multiple of 10 with any three cards, your score is 0, also known as "Bull Fizzle."
For example, the score for the cards 5, 3, 2, 3, 4 is 7, also known as "Bull Seven."
Xiao Z found the game not thrilling enough, so he made some modifications to the rules.
Problem Description
Given \( n \) cards, each ranging from 1 to 10. You need to select \( n-2 \) of these cards whose sum is a multiple of 10. The unit digit of the sum of the remaining two cards is your score. Specifically, if the sum of these two cards is a multiple of 10, your score is 10, also known as "Bull Blasting." If no combination of \( n-2 \) cards can form a multiple of 10, your score is 0, also known as "Bull Fizzle."
Since Xiao Z wants to have more fun, he needs you to complete this program to help him know the score within one second.
Input Format
The first line contains an integer \( n \), indicating the total number of cards.
The second line contains \( n \) integers, representing the values of these cards.
Output Format
A single line containing an integer, representing the score of this round, which ranges from 0 to 10.
Sample Input and Output
Sample Input #1
5
10 10 10 2 3
Sample Output #1
5
Sample Input #2
5
3 4 5 6 7
Sample Output #2
0
Notes
[Sample 1 Explanation]
The three cards 10, 10, 10 form a multiple of 10, and \( 2 + 3 = 5 \).
[Sample 2 Explanation]
No combination of three cards can form a multiple of 10.
[Data Range]
This problem uses batched testing.
- Subtask 1 (50 points): \( n = 5 \).
- Subtask 2 (30 points): \( n \le 5 \times 10^3 \).
- Subtask 3 (20 points): No special restrictions.
For 100% of the data, \( 5 \le n \le 10^6 \).
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分