ANCO

Counting by 10s

Time limit: 2sMemory limit: 256 MBPoints: 333

Problem Statement

Baby Stephan just learned how to add numbers! Unfortunately, he only knows how to add two positive one-digit numbers that result in a sum of 10.

As a homework assignment one day, Stephan's teacher gives him NN (2≤N≤1052 \leq N \leq 10^5) one-digit numbers and tells him to find the sum of the NNnumbers. Stephan, using his limited addition knowledge mentioned above, finds his "answer" to the question by selecting a pair of numbers in the NN numbers such that he is able to add the two numbers in the pair up.

The next day, Stephan tells his teacher his "answer", and then his teacher tells Stephan how much he is off by.

Find how much Stephan is off by.

Input Format

The first line contains NN.

The second line contains the NN one-digit numbers (each between 1 and 9), with each number separated by a space.

Output Format

One line with the answer.

Constraints

  • • 2≤N≤1052 \leq N \leq 10^5
  • • Each of the NN numbers is between 1 and 9

Sample Test Cases

Sample Input 1

6
1 2 3 4 6 7

Sample Output 1

3

Explanation: Stephan can choose the pairs (3, 7) and (4, 6), as he is able to do 3+7 and 4+6. The sum of 1+2+3+4+6+7 is 23, and 3+7+4+6=20. So the answer is 23-20=3.

Sample Input 2

5
5 5 5 5 5

Sample Output 2

5

Test Case Information

  • • Test cases 3–6 satisfy N≤100N \leq 100.
  • • Test cases 7–12 satisfy N≤103N \leq 10^3.
  • • Test cases 13–20 satisfy N≤105N \leq 10^5.

Submit Solution (Practice)

You must be logged in to submit.

If you are using C++17, please declare your main method as exactly "int main()", and make sure that your main method returns 0. (Note: You can add other methods, though, just make sure that your main method (the method where your code begins to run) is called "int main()".)

If you are using Java, please name your class exactly "Main".

Submission History

IDLanguageVerdictScoreSubmitted (PST)
No submissions yet.