This page is still under construction.

Parts of this page are still being built. What you see may change.

Choosing subjects

Time limit2sMemory limit512 MB

Summary
Pick the three highest scores among the four science subjects and the higher of history and geography, then print their sum.
Level

Easy1 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Problem

JOI sat exams in six subjects: physics, chemistry, biology, earth science, history and geography. Each exam is worth at most 100 points.

JOI picks three subjects out of physics, chemistry, biology and earth science, and one subject out of history and geography.

Find the total score of the picked subjects when the picks are made so that the total is as large as possible.

Input

The input has six lines, each holding one integer.

The first line holds the physics score AA.

The second line holds the chemistry score BB.

The third line holds the biology score CC.

The fourth line holds the earth science score DD.

The fifth line holds the history score EE.

The sixth line holds the geography score FF.

Every one of AA, BB, CC, DD, EE and FF is an integer between 00 and 100100, inclusive.

Output

Print the total score of the four subjects JOI picked on one line.

Hint

In the first example the total is largest when JOI picks physics, biology, earth science and history. Those four scores are 100, 76, 42 and 10, so the total is 228.

In the second example the total is largest when JOI picks chemistry, biology, earth science and geography. Those four scores are 21, 15, 42 and 62, so the total is 140.

Examples2

  1. Example 1

    Input
    100
    34
    76
    42
    10
    0
    
    Expected output
    228
    
  2. Example 2

    Input
    15
    21
    15
    42
    15
    62
    
    Expected output
    140