## WC '15 Contest 2 J2 - The Empire Strikes Back

View as PDF

Points: 5
Time limit: 1.0s
Memory limit: 16M

Author:
Problem type
##### Woburn Challenge 2015-16 Round 2 - Junior Division
"Do. Or do not. There is no try/catch."

As part of his intensive Jedi training at the hands of Master Yoda in the Dagobah system, Luke has been given the task of moving some rocks. That may sound simple, but he'll have to move them with his mind, using the power of the Force! Also, some of the rocks are rather heavy.

Yoda has laid out rocks on the ground, with the -th rock having a mass of pounds. He's instructed Luke to move all of them to another location, one at a time. Unfortunately, Luke's control of the Force is only strong enough to allow him to lift a rock if its mass is no larger than pounds.

Assuming that Luke tries his best and moves as many of the rocks as he can, what's the total mass of the rocks that he'll lift?

#### Input Specification

The first line of input consists of two space-separated integers and .
The next lines each consist of a single integer , for .

#### Output Specification

Output a single integer – the total mass of rocks that Luke can lift with the force.

#### Sample Input

6 8
4
9
8
12
7
1

#### Sample Output

20

#### Sample Explanation

The nd and th rocks are too heavy for Luke, but he can lift the remaining rocks, which have a total mass of pounds.