Under construction

Still being built. Things may change

Find the Hanyang Student ID!

Time limit1sMemory limit1024 MB

Summary
Given up to five Suneung standard scores, compute the Hanyang student ID from a fixed formula of score differences and products.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

I am Kim Hanyang. After seven attempts at the Suneung, I was admitted to Hanyang University with the class of 2023. While celebrating the acceptance call with friends over drinks, I walked off the road and rolled down a hill. When I woke up, two weeks had passed, and only 15 minutes remained before course registration opened. I got to the registration website, but the injury has left me unable to remember my student ID. The university notice explains how student IDs are generated.

Hanyang University is called the Engine of Korea, so its student IDs follow a special formula. To find the ID, you need the exact Suneung scores (standard scores).

  • If the Korean score is higher than the English score, multiply the difference of the two scores by the building number 508508 of the Humanities Building. Otherwise, multiply the difference of the two scores by the building number 108108 of the International Building.
  • If the math score is higher than the inquiry score, multiply the difference of the two scores by the building number 212212 of the 1st Engineering Building. Otherwise, multiply the difference of the two scores by the building number 305305 of the ITBT Building.
  • If the second foreign language was taken, multiply its score by 707707, the building number of Haengwon Park.
  • Add the three values above, then multiply the sum by the Hanyang University postal code 04763(=4763)04763 (= 4763). The result is the student ID.

Kim Hanyang tried these calculations but found that the head injury makes mental arithmetic impossible. Write a program that calculates the student ID for him. A subject cannot be taken unless the subject before it was taken, and the standard score of a subject that was not taken is 00.

Input

The first line contains an integer T(1≤T≤5)T (1 \leq T \leq 5), the number of subjects Kim Hanyang took. The second line contains TT integers, the standard scores of each subject, separated by spaces. The scores are given in the order Korean, math, English, inquiry, and second foreign language. The inquiry score is the sum of the standard scores of its two subjects. Every score is an integer from 00 to 200200, inclusive.

Output

Print Kim Hanyang's student ID.

Examples3

  1. Example 1

    Input
    5
    88 92 90 90 35
    
    Expected output
    120908755
    
  2. Example 2

    Input
    4
    94 96 90 88
    
    Expected output
    17756464
    
  3. Example 3

    Input
    4
    50 25 25 50
    
    Expected output
    96807975